edit detail datagrid of master/detail??

edit detail datagrid of master/detail??

Post by Les Caudl » Fri, 19 Jul 2002 09:50:05



I can display a master/detail datagrid with no problems.

However, when I attempt to edit the detail datagrid, I follow these
steps:

EditCommand(Object sender, DataGridCommandEventArgs e)

((DataGrid)sender).EditItemIndex = e.Item.ItemIndex;
LoadData();
masterGrid.DataBind();

 but I do not get the edit boxes displaying in the template columns.
In fact, there is no change at all.

I'm creating the nested grids at design time - and use:
datasource='<%#
((DataRowView)Container.DataItem).Row.GetChildRows("MasterDetailRelation")
%>'

to set the detail datasource.

I am perplexed as to why this doesn't work.

Any ideas or working sample code?
--

 
 
 

edit detail datagrid of master/detail??

Post by Jeff Loui » Fri, 19 Jul 2002 13:56:24


Les Caudle.... Not sure this is what you want:
private void Page_Load(object sender, System.EventArgs e)
{
        // Put user code to initialize the page here
        // dataSet11 has two tables Customers and Orders and a
ParentChildRelationship
        // called CustomersOrders (see DataSet1.xsd)
        // DataGrid1 enabled paging with page size of one
        dataSet11.EnforceConstraints= false;
        sqlDataAdapter1.Fill(dataSet11);
        sqlDataAdapter2.Fill(dataSet11);
        dataSet11.EnforceConstraints= true;

        if (!IsPostBack)
        {
                BindControls();
        }

Quote:}

protected void BindControls()
{
        parentView.Table= dataSet11.Tables["Customers"];
        ResetPageIndex(DataGrid1, parentView);  // check for invalid page index
        int currentRow= DataGrid1.CurrentPageIndex; // page size= 1    
        currentParentRow= parentView[currentRow];
        childView= currentParentRow.CreateChildView("CustomersOrders");

        DataGrid1.DataBind();  
        // DataGrid2 is unbound
        DataGrid2.DataSource= childView;
        ResetPageIndex(DataGrid2, childView);
        DataGrid2.DataBind();

Quote:}

// Our UTILITY functions.
..

protected void DataGrid1_Page(Object sender,
DataGridPageChangedEventArgs e)
        {
        DataGrid1.CurrentPageIndex= e.NewPageIndex;
        DataGrid1.EditItemIndex = -1;
        BindControls();

Quote:}

protected void DataGrid2_Edit(Object sender, DataGridCommandEventArgs e)
{
        DataGrid2.EditItemIndex = e.Item.ItemIndex;
        BindControls();

Quote:}

protected void DataGrid2_Cancel(Object sender, DataGridCommandEventArgs
e)
{
        DataGrid2.EditItemIndex = -1;
        BindControls();

Quote:}

Regards,
Jeff
Quote:>I can display a master/detail datagrid with no problems.

However, when I attempt to edit the detail datagrid, I am perplexed as
to why this doesn't work.
Any ideas or working sample code?<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!