SEARCH YOUR SOLUTION HERE  

Advanced use of DataGrid...

Hi ,
I need to display a DataGrid that serves as a cross tab. The columns will be all coming from just one field/column of a database table (not from different columns as it's usually done). This field will have different values and each different value will make up a column in the datagrid. The values in the database field will serve as the text for each datagrid column.

The rows should be similar. They will be made up of just one column in a database table. The different values in the database column will be the row headings in the datagrid. This will be just the heading of the rows. The values in the rows that correspond to all the columns of the datagrid will not be values but checkboxes that the user will be able to click.

OK, I'll say it again so that you could understand what I'm saying: I need a datagrid with column headings and row headings only. Everything else in the datagrid should be checkboxes. Each check box will be a match of a row and a column heading (i.e. a Cross Tab). The user should be able to check/uncheck the checkboxes and based on what he checks/unchecks, I will take a appropriate action.

Now, I don't quite know how to implement this. Can anybody please point me in the right direction I don't know if the DataGrid control is the best choice for what I need, so if anyone would give me other ideas, I would really appreciate it.

Posted On: Tuesday 27th of November 2012 11:30:57 PM Total Views:  195
View Complete with Replies




Related Messages:

Re: More advanced gridview updating   (104 Views)
The page I'm working on now has a more advanced gridview than my previous one and the update isn't working. This is going to be a very long explanation. I apologize in advance. I call a stored procedure which returns me 79 rows that contain one column, a date. The rows are from 11/1/2001 to 5/1/2008. Then I take each of these dates and make another stored procedure call which gives me data for each date. This is the definition of my gridview: Code: I populate the Market Cost and Actual/Estimate columns in the code-behind: Code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then PopulateGrid() End Sub Sub PopulateGrid() Dim sPrice As String = "" Dim sDescription As String = "" ' Me.gvMarketAreaMonthly.DataBind() Try For i As Integer = 0 To Me.gvMarketAreaMonthly.Rows.Count - 1 Dim labelMonth As Label = DirectCast(Me.gvMarketAreaMonthly.Rows(i).FindControl("lblMonth"), Label) GetMarketAreaMonthlyData(labelMonth.Text, sPrice, sDescription) Dim labelMarketCost As Label = DirectCast(Me.gvMarketAreaMonthly.Rows(i).FindControl("lblMarketCost"), Label) If Not labelMarketCost Is Nothing Then labelMarketCost.Text = FormatCurrency(sPrice) Dim txtMarketCost As TextBox = DirectCast(Me.gvMarketAreaMonthly.Rows(i).FindControl("txtMarketCost"), TextBox) If Not txtMarketCost Is Nothing Then txtMarketCost.Text = FormatCurrency(sPrice) Dim lblMarketCostActOrEst As Label = DirectCast(Me.gvMarketAreaMonthly.Rows(i).FindControl("lblMarketCostActOrEst"), Label) If Not lblMarketCostActOrEst Is Nothing Then lblMarketCostActOrEst.Text = sDescription Dim txtMarketCostActOrEst As TextBox = DirectCast(Me.gvMarketAreaMonthly.Rows(i).FindControl("txtMarketCostActOrEst"), TextBox) If Not txtMarketCostActOrEst Is Nothing Then txtMarketCost.Text = FormatCurrency(sPrice) Next Catch ex As Exception Dim t As Type = Me.[GetType]() If Not ClientScript.IsClientScriptBlockRegistered(t, "ExceptionMessage") Then ClientScript.RegisterClientScriptBlock(t, "ExceptionMessage", "alert('" & ex.Message & "');") End If End Try End Sub So basically, when I am editing I want to see textboxes with the data and when I am viewing I want to see labels with the data. When I am viewing, the data appears in my grid. When I press the Edit button and leave view mode and enter edit mode, all my data goes away except for the month column (because I don't have an EditItemTemplate defined for it, I guess). This page is much like the one I worked on yesterday, the only thing different being I don't get all my data from one stored procedure. I can't believe that difference would screw everything up so badly. Please help. I can't think of anything else to try. If you need to see screen shots of my data when I have it and when I don't, I can attach those.
[C#] Webcontrol help advanced radiobutton   (243 Views)
Hiya! I have a kind of problem. There is a page with radio buttons. Their code is like this: The value is the player on this game, so it changes. I want to only click the radio button with a specific value My code for clicking the first on the page is: this.wb2.document.["id"].InvokeMember("click"); How do i rewrite this to click only those with 1234 as value, and not click after name. this.wb2.document.["1234"].InvokeMember("click"); Does not work Please give me a hand
Explain object use; using object before it's constructed   (181 Views)
I think I have a fair grip on OOP, but this part of VB.NET has me a bit confused:CODEsub Page_Load(sender As Object, e As EventArgs)dim maxDaysNewMonth as integer = datetime.DaysInMonth(1996, 2)response.write(maxDaysNewMonth)end subWhat confuses me is the datetime method call. My can I use a method of this class, when I havn't created the object yet Is this an object that is made available to me my the .NET framework somehow The page somehow makes this object availabe to me, just like the response object I looked in MSDN, and they don't even call this a class, but rather a structure, but it still has methods.Does anyone have any insight into this Any pointers LinksI mean, I wouldn't do this:CODEdim intStringLength = String("Steve").Length
how to use COM component in Web Application in ASP.NET   (208 Views)
Does anyone can tell me how to use COM component in WebApplication in ASP.NET with VBNow I have to use a third-party COM component(CCNSMTLib) inmy project to play a wave file and send it out to differentIP phones.It works fine in windows application in ASP.NET, but when I convert the code into web application, it does not work.When I click the "Start" button in web application, the WebPage is freezing for ever. When I set breakpoint to debug, the program is block at the statement "Dim obj As New CCNMediaTerm".Following is the code for windows application:========================================================Imports CCNSMTLibPublic Class Form1Inherits System.Windows.Forms.FormPrivate Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim obj As New CCNMediaTerm Dim mfpp As UInt16 mfpp = System.Convert.ToUInt16(0) Dim sendFileCookie As Integer Call obj.Initialize() Call obj.SetAudioCodecTX(4, 20, 0, 0, mfpp, 0) Call obj.SetAudioDestination("172.20.10.138", 30000) Dim waveDevice, mode, volume As UInt32 waveDevice = System.Convert.ToUInt32(-1) mode = System.Convert.ToUInt32(1) volume = System.Convert.ToUInt32(80) obj.StartTX(waveDevice) obj.StartPlayingFileTX("C:\system_error.wav", _ mode, volume, sendFileCookie) End Sub End Class===========================================================Following is the code for Web Application===========================================================Imports CCNSMTLibPublic Class rtpPlay Inherits System.Web.UI.PagePrivate Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_Start.Click Dim obj As New CCNMediaTerm Dim mfpp As UInt16 mfpp = System.Convert.ToUInt16(0) Dim sendFileCookie As Integer Call obj.Initialize() Call obj.SetAudioCodecTX(4, 20, 0, 0, mfpp, 0) Call obj.SetAudioDestination("172.20.10.138", 30000) Dim waveDevice, mode, volume As UInt32 waveDevice = System.Convert.ToUInt32(-1) mode = System.Convert.ToUInt32(1) volume = System.Convert.ToUInt32(80) obj.StartTX(waveDevice) obj.StartPlayingFileTX("C:\system_error.wav", _ mode, volume, sendFileCookie)End SubPrivate Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page hereEnd SubEnd Class============================================================
Declaring a class for use throughout a code behind page   (191 Views)
Hi ,I'm trying to find a way to declare a class in a code behind page that will allow me to use it within different functions and procedures without having to declare it each time.Another question while I'm asking, when I declare the class, I pass it a userID which is stored as a session variable. Should i use a session variable, or would a cookie be bette
how to use writer.WriteStartAttribute?   (120 Views)
I'm creating some RSS feeds and in one of them i would like to include comments.According to the specs i need to include CODE http://bitworking.org/news/commentsRss/52 (see e.g. http://www.sellsbrothers.com/spout/#exposingRssComments)Now how do i do this with C#/asp.net Something like :CODEwriter.WriteStartAttribute("wfw", "commentRss", "http://wellformedweb.org/CommentAPI/");writer.WriteString("http://test");writer.WriteEndAttribute(); --------------------------------------http://de-leau.eigenstart.nl
Which Control caused PostBack?   (163 Views)
I have a dropdown list and button that cause postback, each with events that are getting fired correctly after Page_Load. How can I determine which control caused the postback in OnInit()
pass multiple parameter to where clause   (175 Views)
I have a stored procedure:@product ID integer"SELECT * FROM testtbl WHERE itemID = @productIDASP page with datagrid of product listing with checkbox column and submit button. Users check interested items, click submit, and redirects to detail page with product ID as URL parameter. The detail page should rund the stored procedure WHERE itemID = URL parameter. Not to sure on the syntax of passing WHERE parameters. It works fine if there is only one parameter. But not when users have selected multiple items (test.aspxproductID=1&productID=3&productID=8).I have a function "parse()"that parses the above example to "1 or productID = 3 or productID = 8". This caused error because @productID as Integer and parse() is string. So I've changed @productID as nvarchar. But then it only displays itemid=1, Everything after the first digit is ignored. I've also changed the stored procedure:@productID as nvarcharSELECT * FROM test WHERE itemID IN (@productID)Changed parse() function to return format as (1,3,8). But this still only returns result with itemid=1I'm using Dreamweaver where:CommandText='dbo.storeproc'parameter =@producID value='Can someone tell me how to get this to work, or is there another way of doing this
?web user control? on multiple pages   (140 Views)
Maybe I'm going about this the wrong way so please feel free to offer a better choice instead of solution...I need a custom toolbar on several pages. The toolbar will have the same functionality on every page but handle data specific to that page. i.e. btnSave on person.aspx will need to verify name is populated and then issue query to save to person table. btnSave when on the product page will verify it's items then save to the product table.I didn't want to have to build the same toolbar on every page so I built the web user control. I thought I could put something like Private Sub btnSave_onclick() on every page and that would handle it's own custom checking and procedures.My problem is webform1.aspx cannot recognize btnSave or even the user control in code view (it will display the user control in the browser though). I tried a work around by placing Public Sub SaveNow() on the aspx and then usercontrol.ascx added private sub btnSave_onclick() call SaveNow()end sub but then the error is SaveNow is not declared.As a final note, I got the usercontrol onto the web page by dragging it from the Solution Explorer onto the page (which resulted in it adding to the page)thnx!-xeno
Making user_information accessible for all pages   (142 Views)
Hi ,I am new to ASP.NET. Once you a user logs into the web application, I want the following details : User Id,User_Name to be accessible in all pages. However once he closes the session, the information should be lost. What is the best strategy to achieve this functionality
Login failed for user in the SQL server 2000   (95 Views)
Hi all,I have an error when I tried to access to the microsoft sql server 2000 with asp .net. Here is the error:* Error while accessing database.Login failed for user 'IS-3PKK5HMGJMS1\ASPNET'.Microsoft OLE DB Provider for SQL Server***The code of web.config is bellow. It seems the server does not allow me to access through the UserList database because the user 'IS-3PKK5HMGJMS1\ASPNET' is not granted, tell me if I wrong
Certain user control code not executing   (182 Views)
Hi Group,Need a little help on some code in a user control.Since I didn't like the standard ASP.NET calendar control, I created my own and converted it to a user control. But for some reason, I can't get a small block of code to execute unless it's in the Page_load event. Or if it's in a sub that's called on Page_Load.If I place the code anywhere else, it does not execute. And I do not like calling 2 sub's to build my calendar. I would like to have 1 call to do it all.Here is the code:Dim datTodaysDate2 As Date = Date.Now()Dim datDateOfNextMonth As Date Dim datLastDayOfMonth As Date Dim intNumberOfLastDayOfMonth As Integer Dim intCurrentMonth As Integer Dim strFirstDayOfCurrentMonth As String Dim datCurrentYear As Integer = Year(datTodaysDate2) 'Get the current date in mm/dd/yyyy format. datTodaysDate2 = datTodaysDate2.ToString("d") 'Get the current month (1-12). intCurrentMonth = Month(datTodaysDate2) 'Build the first day of the current month in mm/dd/yyyy format. strFirstDayOfCurrentMonth = intCurrentMonth & "/1/" & Year(datTodaysDate2) 'Now add 1 month. datDateOfNextMonth = DateAdd("m", 1, strFirstDayOfCurrentMonth) 'Now subtract 1 day. This is the last day on the previous (current) month. datLastDayOfMonth = DateAdd("d", -1, datDateOfNextMonth) 'Now get the last day (1 - 31) of the current month intNumberOfLastDayOfMonth = Day(datLastDayOfMonth) 'Call sub that builds the URL for our links. BuildCalendarLinks(intCurrentMonth, datCurrentYear, Request.QueryString("month"), Request.QueryString("year"))And here is the sub BuildCalendarLinks:Dim intPreviousMonth As Integer Dim intPreviousYear As Integer Dim intNextMonth As Integer Dim intNextYear As Integer Dim strCurrentMonthName As String Dim intDisplayCurrentYear As Integer 'Start by checking the values passed in. If the URL var's are present, 'we got them from the querystring and need to use them. If not, use the 'first 2 passed in. If IsNumeric(intURLMonth) And IsNumeric(intURLYear) Then 'Check the year/month combo. If month = 1, we need to set the month to 12 'and subtract 1 from the year. If intURLMonth = 12 Then intPreviousMonth = 11 intPreviousYear = intURLYear intNextMonth = 1 intNextYear = intURLYear + 1 ElseIf intURLMonth = 1 Then intPreviousMonth = 12 intPreviousYear = intURLYear - 1 intNextMonth = intURLMonth + 1 intNextYear = intURLYear Else intPreviousMonth = intURLMonth - 1 intPreviousYear = intURLYear intNextMonth = intURLMonth + 1 intNextYear = intURLYear End If intDisplayCurrentYear = intURLYear strCurrentMonthName = GetShortMonthName(intURLMonth) Else 'No URL values passed in. Use the first. 'Check the year/month combo. If month = 1, we need to set the month to 12 'and subtract 1 from the year. If intCurrentMonth = 12 Then intPreviousMonth = 11 intPreviousYear = intCurrentYear - 1 intNextMonth = 1 intNextYear = intCurrentYear + 1 Else intPreviousMonth = intCurrentMonth - 1 intPreviousYear = intCurrentYear intNextMonth = intCurrentMonth + 1 intNextYear = intCurrentYear End If intDisplayCurrentYear = intCurrentYear strCurrentMonthName = GetShortMonthName(intCurrentMonth) End If 'Since we are done, update the links on the page. We need to set the next 'and previous links with the next & previous month/year combo. PreviousMonth.NavigateUrl = ("CalendarDetails.aspxmonth=" & intPreviousMonth & "&year=" & intPreviousYear) PreviousMonth.Text = "<<" NextMonth.NavigateUrl = ("CalendarDetails.aspxmonth=" & intNextMonth & "&year=" & intNextYear) NextMonth.Text = ">>" 'Let's also build the month.year header. MonthYear.Text = strCurrentMonthName & " " & intDisplayCurrentYearSorry for all the code
Login failed for user in the SQL server 2000   (209 Views)
Hi all,I have an error when I tried to access to the microsoft sql server 2000 with asp .net. Here is the error:* Error while accessing database.Login failed for user 'IS-3PKK5HMGJMS1\ASPNET'.Microsoft OLE DB Provider for SQL Server***The code of web.config is bellow. It seems the server does not allow me to access through the UserList database because the user 'IS-3PKK5HMGJMS1\ASPNET' is not granted, tell me if I wrong
Certain user control code not executing   (138 Views)
Hi Group,Need a little help on some code in a user control.Since I didn't like the standard ASP.NET calendar control, I created my own and converted it to a user control. But for some reason, I can't get a small block of code to execute unless it's in the Page_load event. Or if it's in a sub that's called on Page_Load.If I place the code anywhere else, it does not execute. And I do not like calling 2 sub's to build my calendar. I would like to have 1 call to do it all.Here is the code:Dim datTodaysDate2 As Date = Date.Now()Dim datDateOfNextMonth As Date Dim datLastDayOfMonth As Date Dim intNumberOfLastDayOfMonth As Integer Dim intCurrentMonth As Integer Dim strFirstDayOfCurrentMonth As String Dim datCurrentYear As Integer = Year(datTodaysDate2) 'Get the current date in mm/dd/yyyy format. datTodaysDate2 = datTodaysDate2.ToString("d") 'Get the current month (1-12). intCurrentMonth = Month(datTodaysDate2) 'Build the first day of the current month in mm/dd/yyyy format. strFirstDayOfCurrentMonth = intCurrentMonth & "/1/" & Year(datTodaysDate2) 'Now add 1 month. datDateOfNextMonth = DateAdd("m", 1, strFirstDayOfCurrentMonth) 'Now subtract 1 day. This is the last day on the previous (current) month. datLastDayOfMonth = DateAdd("d", -1, datDateOfNextMonth) 'Now get the last day (1 - 31) of the current month intNumberOfLastDayOfMonth = Day(datLastDayOfMonth) 'Call sub that builds the URL for our links. BuildCalendarLinks(intCurrentMonth, datCurrentYear, Request.QueryString("month"), Request.QueryString("year"))And here is the sub BuildCalendarLinks:Dim intPreviousMonth As Integer Dim intPreviousYear As Integer Dim intNextMonth As Integer Dim intNextYear As Integer Dim strCurrentMonthName As String Dim intDisplayCurrentYear As Integer 'Start by checking the values passed in. If the URL var's are present, 'we got them from the querystring and need to use them. If not, use the 'first 2 passed in. If IsNumeric(intURLMonth) And IsNumeric(intURLYear) Then 'Check the year/month combo. If month = 1, we need to set the month to 12 'and subtract 1 from the year. If intURLMonth = 12 Then intPreviousMonth = 11 intPreviousYear = intURLYear intNextMonth = 1 intNextYear = intURLYear + 1 ElseIf intURLMonth = 1 Then intPreviousMonth = 12 intPreviousYear = intURLYear - 1 intNextMonth = intURLMonth + 1 intNextYear = intURLYear Else intPreviousMonth = intURLMonth - 1 intPreviousYear = intURLYear intNextMonth = intURLMonth + 1 intNextYear = intURLYear End If intDisplayCurrentYear = intURLYear strCurrentMonthName = GetShortMonthName(intURLMonth) Else 'No URL values passed in. Use the first. 'Check the year/month combo. If month = 1, we need to set the month to 12 'and subtract 1 from the year. If intCurrentMonth = 12 Then intPreviousMonth = 11 intPreviousYear = intCurrentYear - 1 intNextMonth = 1 intNextYear = intCurrentYear + 1 Else intPreviousMonth = intCurrentMonth - 1 intPreviousYear = intCurrentYear intNextMonth = intCurrentMonth + 1 intNextYear = intCurrentYear End If intDisplayCurrentYear = intCurrentYear strCurrentMonthName = GetShortMonthName(intCurrentMonth) End If 'Since we are done, update the links on the page. We need to set the next 'and previous links with the next & previous month/year combo. PreviousMonth.NavigateUrl = ("CalendarDetails.aspxmonth=" & intPreviousMonth & "&year=" & intPreviousYear) PreviousMonth.Text = "<<" NextMonth.NavigateUrl = ("CalendarDetails.aspxmonth=" & intNextMonth & "&year=" & intNextYear) NextMonth.Text = ">>" 'Let's also build the month.year header. MonthYear.Text = strCurrentMonthName & " " & intDisplayCurrentYearSorry for all the code
Why use a OledbCommandBuilder Object?   (86 Views)
I have been playing with a test program and am confused as to why I would use an OledbCommandBuilder object. The book says that it is handy as it looks at the SelectCommand property you give it and it creates the appropriate commands from it. But when I use it in my example, there is no difference. I end up creating an object(including the overhead involved)that doesn't seem necessary.CODESub GetAd(AdNumSent As Integer)SelectStatement = "Select * From Ads Where AdNum=" & _ AdNumSentConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\inetpub\wwwroot\simplyClassy\classydb.mdb"Connect.ConnectionString = ConnectStringAdapter.SelectCommand = _ new OleDbCommand(SelectStatement, Connect)' ClassyCB = New OleDbCommandBuilder(Adapter)Adapter.SelectCommand.Connection.OpenAdapter.Fill(ClassyDS,"Ads")End SubI can switch the comment and it will still work:CODEClassyCB = New OleDbCommandBuilder(Adapter)'Adapter.SelectCommand.Connection.OpenI don't see the use for this (at least in this context).Tom.
Syntax error in query. Incomplete query clause.   (95 Views)
Pardon my ignorance, but I am trying to update a database table, and have tried to use the book to help me, and I've typed everything exactly as it's shown (except for my DB variables that I've changed) but it's erroring telling me the following: Exception Details: System.Data.OleDb.OleDbException: Syntax error in query. Incomplete query clause. Line 21.Line 19: Line 20: oCmd = New OleDbCommand(sSQL, oConn)Line 21: oCmd.ExecuteNonQuery()Line 22: Line 23: lblStatus.Text = "Command Run"My code is pretty simple (I think) What is wrong with the syntax of the oCmd.ExecuteNonQuery() command-If seeing the entire code would be more helpful I can provide.Thank you VERY much in advance.J
Inline Code problem with user control property   (214 Views)
Hi all,i have a problem, when i try to place a inline tag to pass a variable to a user control property.I have Dim Section As Integer = 2 as a global variable, and then i have:Now i am not sure, but i thought i could use the inline tags in .Net, but i am not 100% sure of the syntax, can anyone help me to find out what i am doing wrong Please Help
List all roles a user is in?   (181 Views)
all! I have a quick question....Does anyone know how to list all the roles a user is in without having to do:CODEif user.isinrole("admin") then Response.write("Is admin")end ifIf users.isinrole("blah") thenetc...I can't seem to find anything like that.
Give full permission rights to the ASPNET user   (98 Views)
,I am new to ASP.NET and I am trying to install a component in VS.NET. I am following some instructions on how to do it, however I encountered the following line:-Give full permission rights to the ASPNET user How do you do tha
mouse over on image hyperlink opposed to image button   (212 Views)
I have a mouse over event that will change the graphic of a button using javascript pretty straight forward. I use the same logic on a hyperlink, but the mouse over event does not seem to change the object. Here's my code'Image ButtonImgBtnChoice.Attributes.Add("onmouseover", "this.src='/GalleryCatalog/Image/arrow_sel.gif';")ImgBtnChoice.Attributes.Add("onmouseout", "this.src='/GalleryCatalog/Image/arrow_unsel.gif';")'HyperlinklnkAdvanceBid.Attributes.Add("onmouseover", "this.src='/GalleryCatalog/Image/arrow_sel.gif';")lnkAdvanceBid.Attributes.Add("onmouseout", "this.src='/GalleryCatalog/Image/arrow_unsel.gif';")If I make the hyperlink button an image button it works fine. Any ideas Jason MeckleyDatabase AnalystWITF