I have following code in my page:
<ig:WebDataGrid ID="AuditDataWebGrid" runat="server" oncolumnsorted="AuditDataWebGrid_ColumnSorted" ondatafiltering="AuditDataWebGrid_DataFiltering"oncolumnmoved="AuditDataWebGrid_ColumnMoved" oninitializerow="AuditDataWebGrid_InitializeRow"EnableAjax="false" Width="100%" ><Behaviors> <ig:ColumnMoving> </ig:ColumnMoving> <ig:Filtering> </ig:Filtering> <ig:Paging PageSize="25" PagerAppearance="Both" PagerMode="NextPreviousFirstLast"> <PagerTemplate> <uc1:PagingUserControl ID="PagingUserControl" runat="server" /> </PagerTemplate> </ig:Paging> <ig:Sorting SortingMode="Multi"> </ig:Sorting></Behaviors><Columns> <ig:TemplateDataField Header-Text="" Key="IS_SELECTED"> <HeaderTemplate> <asp:CheckBox ID="MultiSelectCheckBox" ToolTip = "Select/Deselect all rows" runat="server" AutoPostBack="true" OnCheckedChanged="MultiSelectCheckBox_OnCheckedChanged" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="IsSelectedCheckBox" runat="server" Enabled="true" AutoPostBack="true" OnCheckedChanged="IsSelectedCheckBox_OnCheckedChanged" /> </ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Header-Text="Status" Key="STATUS"> <HeaderTemplate> <label>Status : </label> <asp:DropDownList ID="StatusFilterDropDownList" runat="server" DataTextField = "DisplayText" DataValueField = "AuditStatusId" AutoPostBack="true" OnSelectedIndexChanged="StatusFilterDropDownList_OnSelectedIndexChanged"></asp:DropDownList> </HeaderTemplate> <ItemTemplate> <asp:DropDownList ID="StatusDropDownList" AutoPostBack="false" runat="server" DataTextField="DisplayText" DataValueField="AuditStatusId"> </asp:DropDownList> </ItemTemplate> </ig:TemplateDataField></Columns></ig:WebDataGrid>
What I'm doing is looping through the WebdataGrid as follow:
foreach (GridRecord gridrow in AuditDataWebGrid.Rows){ CheckBox chk = gridrow.FindControl("IsSelectedCheckBox") as CheckBox;}
But I'm always getting chk = null.
What is the way to find this control in the GridRecord? or what should be the way to accomplish this?
Thanks
OscarG
Did you ever get this to work? I always get a null object reference.
Here is what I'm doing to get the control.
foreach (GridRecord gridrow in AuditDataWebGrid.Rows){ CheckBox chk = gridrow.Items[AuditDataWebGrid.Columns["IS_SELECTED"].Index].FindControl("IsSelectedCheckBox") as CheckBox; }
Now the problem is following: I know I checked the checkbox but when I got the control it say it is not checked. Why value is not posted back?