Hi,
I am trying to do something simple with WebDataGrid. Let's say I want to do as following, use a templatedatafield and register the control event to be handled server-side (not client-side):
<
igt:TemplateDataField Key="Wty"><Header Text="Warranty" /><ItemTemplate>
<asp:CheckBox ID="cbWarranty" runat="server" AutoPostBack="true" Checked='<%# Bind("Warranty")%>' OnCheckedChanged="Warranty_CheckedChanged"/>
</ItemTemplate></igt:TemplateDataField>
Since it is in a template, I figured out that I would need to register the CheckedChanged event on initialization of the grid, hence OnInitializeRow:
protected void grid_InitializeRow(object sender, RowEventArgs e)
{
CheckBox cb = e.Row.Items[wtyCellIndex].FindControl("cbWarranty") as CheckBox;
cb.CheckedChanged -=
new EventHandler(Warranty_CheckedChanged);
cb.CheckedChanged += new EventHandler(Warranty_CheckedChanged);
}
Now, my problem is the event doesn't get triggered at all. Can someone explain me how should it be done?
Thank you.
What is your data source and how the grid is being bound to it?
Try using EnableDataViewState property and bind the grid only once when it is !this.IsPostBack.
Another thing to try is instead of handling CheckedChanged off of every control, maybe it'd make it easier for you to handle ItemCommand off the grid itself.