CheckBoxes in Detail of Master/Detail Datagrid

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

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories