Note: When binding data from a table's Aspxgridview (OnDataBinding () event)-----Code is as follows
Binding attribute Value table
protected void Grid2_sontable_databinding (object sender, EventArgs e)
{
Aspxgridview Songrid = (aspxgridview) sender; Instantiating from a table table
Object _faterid = Songrid. Getmasterrowkeyvalue (); Get the primary table row ID (id value in template grid)
DataTable dt = new DataTable ();
DT = Goodsmanagebll. Get_getattributevaluelistbyattrid (int. Parse (_faterid. ToString ())). Tables[0];
Songrid. DataSource = DT;
}
GridView Master table:
Master-Slave Table binding code map:
Master-Slave table front-end code
<dx:aspxgridview id= "ASPxGridView2" clientinstancename= "ASPxGridView2" runat= "Server" width= "55%" autogeneratecolumns= "False" keyfieldname= "Attrid" theme= "Mulberry"
Onhtmldatacellprepared= "aspxgridview2_htmldatacellprepared" onhtmleditformcreated= "ASPxGridView2_ Htmleditformcreated "onrowdeleting=" aspxgridview2_rowdeleting "
onrowupdating= "aspxgridview2_rowupdating" onrowinserting= "aspxgridview2_rowinserting" >
<clientsideevents endcallback= "Grid2_endcallback"/>
<settingstext emptydatarow= "No data" commandedit= "Modify"/>
<settingsediting mode= "Popupeditform" ></SettingsEditing>
<settingsdetail showdetailrow= "true" allowonlyonemasterrowexpanded= "true"/>
<Styles>
<%--<alternatingrow enabled= "True"/>
<commandcolumn spacing= "10px" wrap= "False"/>--%>
<%--<cell horizontalalign= "Center" ></Cell>
<table cssclass= "Tw-datatable" ></Table>
<commandcolumn cssclass= "Tw-commandcolumn" ></CommandColumn>
<commandcolumnitem cssclass= "Tw-commandcolumnbtn" ></CommandColumnItem>
<focusedrow cssclass= "Tw-focusrow" ></FocusedRow>
</Styles>
<settingspager pagesize= "Ten"/>
<settingsbehavior allowfocusedrow= "True"/>
<settingsediting mode= "Popupeditform" ></SettingsEditing>
<settings gridlines= "Horizontal"/>
<SettingsPopup>
<editform modal= "true" horizontalalign= "Windowcenter" verticalalign= "Windowcenter"/>
</SettingsPopup>
<settingsbehavior confirmdelete= "true"/>
<settingstext confirmdelete= "Are you sure you want to delete it? "/>
<settingsdetail showdetailrow= "true"/>
<Columns>
<dx:gridviewdatacolumn caption= "Number" visibleindex= "1" fieldname= "Attrid" width= "2%" ></DX: Gridviewdatacolumn>
<dx:gridviewdatacolumn caption= "Property name" visibleindex= "2" fieldname= "Attrname" width= "20%" ></DX: Gridviewdatacolumn>
<dx:gridviewdatacomboboxcolumn caption= "attribute grouping" visibleindex= "3" fieldname= "Attrgroupid" Width= "20%" >
<propertiescombobox textfield= "Attrgroupname" valuefield= "Attrgroupid" valuetype= "System.Int32" ></ Propertiescombobox>
</dx:GridViewDataComboBoxColumn>
<dx:gridviewdatacomboboxcolumn caption= "Display Type" visibleindex= "4" fieldname= "ShowType" width= "3%" >
<PropertiesComboBox>
<Items>
<dx:listedititem value= "0" text= "text"/>
<dx:listedititem value= "1" text= "Pictures"/>
</Items>
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
<dx:gridviewdatacomboboxcolumn caption= "Filter Properties" visibleindex= "5" fieldname= "Isfilter" width= "3%" >
<PropertiesComboBox>
<Items>
<dx:listedititem value= "0" text= "no"/>
<dx:listedititem value= "1" text= "yes"/>
</Items>
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
<dx:gridviewdatacolumn caption= "Sort" visibleindex= "6" fieldname= "Displayorder" width= "2%" ></DX: Gridviewdatacolumn>
<dx:gridviewcommandcolumn caption= "Universal price operation" Showeditbutton= "true" shownewbuttoninheader= "true" showdeletebutton= " True "showincustomizationform=" true "visibleindex=" 7 "width=" 8% ">
<editbutton text= "Modify" ></EditButton>
</dx:GridViewCommandColumn>
</Columns>
<Templates>
<%--from Table--%>
<DetailRow>
<p style= "color: #b7245f; font-size:13px;font-weight:bold;" > Attribute Values list </p>
<dx:aspxgridview id= "grid2_sontable" clientinstancename= "grid2_sontable" runat= "Server" Width= "22%" autogeneratecolumns= "False" keyfieldname= "Attrvalueid" theme= "Mulberry"
ondatabinding= "grid2_sontable_databinding" onrowupdating= "grid2_sontable_rowupdating" OnRowDeleting= "grid2_ Sontable_rowdeleting "onrowinserting=" grid2_sontable_rowinserting "onhtmleditformcreated=" Grid2_sonTable_ Htmleditformcreated ">
<clientsideevents endcallback= "Grid2_sontable_endcallback"/>
<settingstext emptydatarow= "No data" commandedit= "Modify"/>
<settingsediting mode= "Popupeditform" ></SettingsEditing>
<Styles>
<alternatingrow enabled= "True"/>
<commandcolumn spacing= "10px" wrap= "False"/>
<%--
<%--<table cssclass= "Tw-datatable" ></Table>
<commandcolumn cssclass= "Tw-commandcolumn" ></CommandColumn>
<commandcolumnitem cssclass= "Tw-commandcolumnbtn" ></CommandColumnItem>
<focusedrow cssclass= "Tw-focusrow" ></FocusedRow>
<cell horizontalalign= "Center" ></Cell>
</Styles>
<settingsbehavior confirmdelete= "true"/>
<settingstext confirmdelete= "Are you sure you want to delete it? "/>
<settingspager pagesize= "Ten"/>
<settingsbehavior allowfocusedrow= "True"/>
<settingsediting mode= "Popupeditform" ></SettingsEditing>
<settings gridlines= "Horizontal"/>
<SettingsPopup>
<editform modal= "true" horizontalalign= "Windowcenter" verticalalign= "Windowcenter"/>
</SettingsPopup>
<Columns>
<dx:gridviewdatacolumn caption= "Number" visibleindex= "1" fieldname= "Attrvalueid" width= "2%" ></DX: Gridviewdatacolumn>
<dx:gridviewdatacolumn caption= "attribute value" visibleindex= "2" fieldname= "ATTRVALUE" width= "5%" ></DX: Gridviewdatacolumn>
<%--<dx:gridviewdatacolumn caption= "owning attribute" visibleindex= "3" fieldname= "Attrname" ></DX: Gridviewdatacolumn>--%>
<dx:gridviewdatacolumn caption= "Sort" visibleindex= "4" fieldname= "Attrvaluedisplayorder" Width= "2%" ></DX: Gridviewdatacolumn>
<dx:gridviewdatacolumn caption= "Property id" visibleindex= "6" fieldname= "Attrid" visible= "false" ></DX: Gridviewdatacolumn>
<dx:gridviewdatacolumn caption= "attribute group ID" visibleindex= "6" fieldname= "Attrgroupid" visible= "false" ></DX: Gridviewdatacolumn>
<dx:gridviewdatacolumn caption= "Property name" visibleindex= "2" fieldname= "Attrname" width= "5%" ></DX: Gridviewdatacolumn>
<dx:gridviewcommandcolumn caption= "Universal price operation" Showeditbutton= "true" showdeletebutton= "true" shownewbuttoninheader= " True "showincustomizationform=" true "visibleindex=" 5 "width=" 8% ">
<editbutton text= "Modify" ></EditButton>
</dx:GridViewCommandColumn>
</Columns>
</dx:ASPxGridView>
</DetailRow>
</Templates>
</dx:ASPxGridView>
How to bind data to master and slave tables in Aspxgridview