0

I have a checkbox column, which has a OnCheckedChanged event.
To avoid postbacks I have placed the checkbox control in UpdatePanel but still it is postbacking
When i execute run the page, i see the postback is still happening.
I dont know whats wrong with my code.

<asp:TemplateField>
<ItemTemplate>
<asp:Literal ID="ltrl" runat="server" Text='<%# Eval("Name") %>'></asp:Literal>
<asp:HiddenField ID="chkId" runat="server" Value='<%# Eval("ControlName") %>' />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:CheckBox ID="chekBox" runat="server" Text='<%# Eval("Name") %>' Checked='<%# Eval("Check") %>'
AutoPostBack="true" OnCheckedChanged="chekBox_CheckedChanged" />                                                
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
3
Contributors
3
Replies
12
Views
3 Years
Discussion Span
Last Post by EddyC27
0

AutoPostBack="true"

That is why you get postbacks. If you disable it, I don't think the OnCheckedChanged will be called. So decide which you need most.

0

I take it you are binding a bit to the checkbox on load from your

Text='<%# Eval("Name") %>' Checked='<%# Eval("Check") %>'

section.

It will postback because binding to the checkbox triggers the check change event

Edited by pritaeas: Added markdown.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.