Edit Items In Nested DataGrid within another DataGrid:
Posted on 2006-11-09
I will try my best to describe what I'm attempting. I have a master data grid, dgMasterData, that is bound on page load that grabs all items of a particular category. The binding is handled by a sub "BindData()" that I have written in my page code behind. In dgMasterData, I have <Columns> tag that shows the results from "BindData()" -- which is basically a category. Under the <Columns>, I bult a <asp:TemplateColumn>. Within this TemplateColumn, I inserted another DataGrid, dgDetails. The real query work (the one I'm interested in editing) is done within this nested DataGrid. Only thing is, I pass the "catg" or category from dgMasterData to a function like this: DataSource=<%# GetDetails(container.dataitem("catg"))%>
In the function, I use "x" as an argument and run a query based off of "x" -- which is the category obtained from the dgMasterData. I basically load a dataset "tblDetails" and return the entire ds like so: Return ds.Tables("tblDetails").
What happens, is that I have a nice dataGrid that has all categories. Within each category, are all of the details for each. Man, this is beauty. However, I now need to edit the items contained in the Nested DataSet, dgDetails. Since I pass this ds from a function, I am not sure how to edit it.
I've set AutoGenerateColumns="false" OnEditCommand="dgDetails_Edit" OnCancelCommand="dgDetails_Cancel" OnUpdateCommand="dgDetails_Update" all within the dgDetials datagrid to do the work. Within the columns of "dgDetails", I set up an <asp:EditCommandColumn> control. Since I basically only have 1 bound column that I want to edit, so I set all others to "readonly=true".
Now, the real editing will take place on the 3 functions listed in the dgDetails datagrid properties.
Sub dgDetails_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Sub dgDetails_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Sub dgDetails_Cancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
I normally update/edit using the "e.Item.ItemIndex" values in a single DataGrid, but I'm not sure where to go from here. I'm asking you wonderful guru's to point me in the right direction or give me some ideas. I thank all of you in advance!