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>

Recommended Answers

All 3 Replies

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.

But I have Added it in Update Panel then it should stop

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.