codetoad.com
Home||ASP|ASP.Net|C++/C#|DHTML|HTML|Java|Javascript|Perl|VB|XML||CodeToadPlus!||Forums||RAM
Search Site:
Search Forums:
Controls in Detail DataGrid of Master/Detail page dhorne41 at 20:46 on Thursday, January 27, 2005

Hi. I am creating a Master/Detail DataGrid page and have run into a problem that I just haven't been able to work through. I have successfully created the Master and Detail DataGrids and they display correctly, however, I need to be able to access Checkboxes that I have added to the Detail datagrid.

The layout is as follows. The page is for selecting Training classes that you would like to register for. The DataGrids are both populated using SQL queries and the data is pulled from an Access database. The Master datagrid contains the months for the training schedule. The Detail datagrid contains the schedule of classes. Next to each Class name in teh Detail DataGrid is a checkbox. The Datagrids are enclosed in a Form with a Register button at the bottom.

The user needs to be able to check the boxes of the classes they would like to take and click the Register button.

Now, I had the site working before I created the Master and Detail grids. It was originally one Datagrid. Clicking Register checks to see which checkboxes are checked using a For...Each loop and finding the checkbox controlls in the current DataGrid. It then populates a Datatable with the data from that row (Declared in a Public Property) and passes it to a second page using Server.Transfer to allow the user to enter registration information and confirm selected classes.

The problem came when I created the Detail datagrid. I can no longer iterate through the checkbox controls in the detail datagrid. I am receiving errors when trying to access the internal datagrid. Here is the error

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 112: Dim inDataGridItem As DataGridItem
Line 113: Dim chkClassSelect As System.Web.UI.WebControls.CheckBox
Line 114: Dim dgNestedSchedule As DataGrid = CType(oDataGridItem.FindControl("dgSchedule"), DataGrid)


I don't get the error until the Register button is actually clicked. The Detail Datagrid is being created using ITemplate from a UserControl file so it is being dynamically added to the first cell of the Master grid.

I have tried resolving in a number of different ways, including trying with and without casting. I am using the FindControls method to locate dgSchedule (the detail grid) within the current cell of dgClasses (the master grid displaying the months). But I still receive this error. How do I go about iterating through checkboxes in the nested grid?

Thanks,

Dustin Horne


Re: Controls in Detail DataGrid of Master/Detail page tgreer at 16:50 on Monday, January 31, 2005

Is the second DataGrid truly nested in that sense? Meaning, is it a child of the first DataGrid, or a child of the Page itself?

Try using Page.FindControl() and see what happens.


Re: Controls in Detail DataGrid of Master/Detail page dev_noob at 17:17 on Monday, April 04, 2005

in your datagrid, use any events (depends on yours)

Private Sub datagridObjects_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles datagridObjects.ItemCommand
If e.CommandName = "displayGrid" Then

Dim dgNestedSchedule As DataGrid = CType(e.FindControl("dgSchedule"), DataGrid)


/* any codes ... */

End If
End Sub








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
matrix addition
Re: Storing data from HTML to Excel or TXT
Re: function within loop problem
Re: Ô‡´ò¥¯¥é¥Ö¤Ï ¥Æ©`¥é©`¥á¥¤¥É£ò£±£±¥¢¥¤¥¢¥ó ¤Î£··¬ ¤Ç¤¹
Re: Replace
Re: タイトリスト AP2アイアン 712�情�
Re: SMS from Perl using HTTP request
Re: Charl Schwartzel
Re: Adhyayan - Annual Student Conference and Online Coding Festival


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


Copyright codetoad.com 2001-2013