i have implemented Web Hirachical Data Grid with N Level of childs . on Save Button i need to get the Checked and unchecked Child bands in code Behind but i am getting 0 count on WebHierarchicalDataGrid1.GridView.Rows[row.Index].RowIslands.
My Code Behind code is :
protected void WebHierarchicalDataGrid1_RowIslandDataBound(object sender, RowIslandEventArgs e) { if (hdgEnterExit.GridView.Rows[0].RowIslands.Count > 0) { var childGrid2 = hdgEnterExit.GridView.Rows[0].RowIslands[0];
foreach (GridRecord record in childGrid2.Rows) { var c = record.Items[0].FindControl("chkChon") as CheckBox;
if (c != null && c.Checked) {
} // userListId += record.Items[1].Value + ";"; } }
}
protected void btnSaveAccessGrid_Click(object sender, EventArgs e) {
foreach (GridRecord row in hdgEnterExit.Rows) { // var b = row.Items[0].FindControl("chkChon") as CheckBox;
// Get row island using data member if (hdgEnterExit.GridView.Rows[row.Index].RowIslands != null && hdgEnterExit.GridView.Rows[row.Index].RowIslands.Count > 0) { var childGrid2 = hdgEnterExit.GridView.Rows[row.Index].RowIslands[0];
foreach (GridRecord record in childGrid2.Rows) { var c = record.Items[0].FindControl("Operation") as CheckBox;
if (record.Items[2].Value.Equals("thuynt.bic")) { string x = "1"; } if (c != null && c.Checked) {
} //userListId += record.Items[1].Value + ";"; } }
int count = hdgEnterExit.Rows.Count;
for (int i = 0; i < count; i++) { var a = hdgEnterExit.Bands.FindByDataMember("TRN_CODE").Columns.FromKey("Menu_Label"); //var Bands = hdgEnterExit.Rows[i].Items.Grid.DataKeyFields().; // var row = hdgEnterExit.getChildRow
// if (Convert.ToBoolean(hdgEnterExit.Rows[i].Items.FindItemByKey("Menu_Label").Value) == true) //{
//POST[j] = Convert.ToBoolean(grdPay.Rows[i].Items.FindItemByKey("All_Post_Checkbox").Value) == true ? 1 : 0; //Status[j] = 1; // processed //ParticipantCode[j] = Convert.ToString(grdPay.Rows[i].Items.FindItemByKey("PARTICIPANT_CODE").Value);
//System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-GB"); ////SettlementDate[j] = DateTime.Parse( grdPay.Rows[i].Items.FindItemByKey("SETTLEMENT_DATE").Value.ToString()); ////SettlementDate[j] = Convert.ToDateTime() //SettlementDate[j] = Convert.ToDateTime(grdPay.Rows[i].Items.FindItemByKey("SETTLEMENT_DATE").Value.ToString(), culture); //ProcessedDate[j] = GetSystemDate(); //IsMannual[j] = 1; //LogID[j] = Log_ID; //RefNumber[j] = SystemUtil.GetNextRefNo(CurrentRefernceNumber); //CurrentRefernceNumber = RefNumber[j]; //j = j + 1;
// }
and on Front Side :
<ig:WebHierarchicalDataGrid ID="hdgEnterExit" runat="server" EnableRelativeLayout="True" ShowFooter="False" HeaderCaptionCssClass="HeaderCaptionClass" ItemCssClass="ItemCssClass" AltItemCssClass="AltItemCssClass" FooterCaptionCssClass="HeaderCaptionClass" AutoGenerateColumns="False" AutoGenerateBands="True" DataMember="Module" DataKeyFields="Module_Id" InitialDataBindDepth="-1" Width="860px" EnableDataViewState="true" EnableViewState="true" OnRowIslandDataBound="WebHierarchicalDataGrid1_RowIslandDataBound">
<Columns> <ig:BoundDataField DataFieldName="Module_Id" Key="Module_Id" Footer-Text="Module_Id" Header-Text="Module_Id" CssClass="CenterAlign" Width="70"> </ig:BoundDataField> </Columns> <Columns> <ig:BoundDataField DataFieldName="Module_Label" Key="Module_Label" Footer-Text="Module_Label" Header-Text="Module_Label" CssClass="CenterAlign" Width="120"> </ig:BoundDataField> </Columns>
<Bands> <ig:Band Key="Trn_Id" AutoGenerateColumns="false" DataMember="TRN_CODE" DataKeyFields="Trn_Id"> <Columns> <ig:BoundDataField DataFieldName="Menu_Label" Key="Menu_Label" Header-Text="Menu_Label" CssClass="CenterAlign" Width="520"> </ig:BoundDataField> </Columns>
<Bands> <ig:Band Key="Trn_Id" AutoGenerateColumns="false" DataMember="TRN_Operations" DataKeyFields="Trn_Id,Operation_Id"> <Columns> <ig:BoundDataField DataFieldName="Operation_Id" Key="Operation_Id" Header-Text="Operation_Id" CssClass="CenterAlign" Width="420"> </ig:BoundDataField> <ig:BoundCheckBoxField DataFieldName="Operation" DataType="System.Boolean" VisibleIndex="1" Key="Operation" Width="180px"> <Header Text="Operation" > </Header> </ig:BoundCheckBoxField> </Columns> <Bands> </Bands> </ig:Band> </Bands> </ig:Band> </Bands> <Behaviors> <ig:EditingCore EnableInheritance="True" Enabled="true"> <EditingClientEvents CellValueChanging="WebHierarchicalDataGrid1_Editing_CellValueChanging"/> <Behaviors> <ig:CellEditing EnableInheritance="true"> <EditModeActions EnableOnActive="True" MouseClick="Single" /> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebHierarchicalDataGrid>