Infragistics web datagrid header checkbox Event issue

5.6k Views Asked by At

ISSUE

I am new to infragistics, I am using the webdatagrid in my page. My grid has a check box as one of the fields. The header field is also a check box .

In the server side event( i need this in the server event no client side events:) ) of the header check box . I need to bind the grid .

If header check box is checked i need to display only active records and if its unchecked i need to display all records .

I am implementing this logic in the server function of the header check box and the grid is not binding( ie the values are not changed) in this event .

I am working on this fix for over a week now . Please help

Please see the code below ...........

ASPX

<ig:WebDataGrid ID="WebDataGrid1" runat="server" EnableDataViewState="true" ViewStateMode="Enabled" Height="100%" Width="100%" AutoGenerateColumns="False" OnColumnSorted="WebDataGrid1_ColumnSorted" DataKeyFields="Id">
<Columns>
<ig:BoundDataField DataFieldName="Id" Hidden="True" Key="Id">
<Header Text="BoundColumn_0" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Name" Key="Name">
<Header Text="Name"></Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="ShortName" Key="ShortName">
<Header Text="ShortName"></Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="IsoCode" Key="IsoCode">
<Header Text="IsoCode"></Header>
</ig:BoundDataField>
<ig:TemplateDataField Key="IsActive" Header-Text="IsActive">
<HeaderTemplate>
<asp:CheckBox ID="chkChildIsActive" runat="server" Checked="true" 
Text="IsActive" AutoPostBack="True" 
oncheckedchanged="chkChildIsActive_CheckedChanged">
</asp:CheckBox>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkHIsActive" runat="server" Checked='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "IsActive") %>'>
</asp:CheckBox>
</ItemTemplate>
<Header Text="IsActive" />
</ig:TemplateDataField>
</Columns>
<ClientEvents Click="WebDataGrid1_SingleClick" DoubleClick="WebDataGrid1_DoubleClick" />
<Behaviors>
<ig:Paging PageSize="15" QuickPages="9">
<PagerTemplate>
<uc1:CustomerPagerControl ID="CustomerPager" runat="server" />
</PagerTemplate>
</ig:Paging>
<ig:Sorting>
</ig:Sorting>
<ig:RowSelectors>
</ig:RowSelectors>
<ig:Selection RowSelectType="Single" CellClickAction="Row" CellSelectType="None">
</ig:Selection>
</Behaviors>
</ig:WebDataGrid>

ASPX.cs

// Page load binding data to grid

protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)
{
List<Port> port = PortManager.PortListTestPaging(true);
WebDataGrid1.DataSource = port;
WebDataGrid1.DataBind();
}
}



//Checkbox Event

protected void chkChildIsActive_CheckedChanged(object sender, EventArgs e)
{

CheckBox chkChildIsActive = (CheckBox)sender;

List<Port> port = PortManager.PortListTestPaging(chkChildIsActive.Checked);

WebDataGrid1.DataSource = port;
WebDataGrid1.DataBind();

}

Fixes that i tried from the Infragistics forum:

  1. EnableDataViewState = false : If we give this property to grid then on the checkbox event the grids all data is cleared ( and the check box event is not fired) .

  2. EnableDataViewState = true and WebDataGrid1.ClearDataSource(): Then I had the following error occurred on check box event "Multiple controls with the same ID 'xyz0_4' were found" I have gone through the below link for a fix but failed . http://www.infragistics.com/community/forums/p/65065/329361.aspx

  3. WebDataGrid1.Rows.Clear() & //WebDataGrid1.Columns.Clear() : Both not worked .

  4. I wanted to know what the issue was so itried the same code for a button event with button outside the grid and it worked . So i think its some problem with some of the properties in the webdatagrid that i may have wrongly given . I have gone through all possible work around that were available .

Thanks , Sankardeep V

1

There are 1 best solutions below

0
On

The simplest solution is to move your logic rebinding the grid from your CheckChanged event handler to the Page_PreRender event. To do this you will need to store if the CheckChanged event was fired and what the value of the check box is in private variables to the page and then check them in the PreRender event. This should work the same as it did in a Button click for you.