I have a Gridview inside a updatepanel that has one column with a checkbox in it. When the checkbox is first clicked the OnCheckedChanged Event is fired but any click on after (whether it is the same check box or any other checkbox on the page that event is not fired again)
ASPX code
<asp:UpdatePanel ID="gridUpdatePanel" UpdateMode="Conditional" runat="server" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:GridView ID="gvComponents" runat="server" AutoGenerateColumns="false" CssClass = "ChildGrid" OnRowDataBound="gvComponents_RowDataBound" OnRowCommand="cbREVISION_CheckChanged" ShowHeader="false">
<Columns>
//Other TemplateFields
<asp:TemplateField HeaderText="Revisions Required" Visible="false" ItemStyle-Width="10%" >
<ItemTemplate>
<div style="text-align:center;">
<asp:CheckBox ID="cbREVISION_REQD" runat="server" Enabled="true" Checked='<%# (bool)Eval("REVISION") %>' AutoPostBack="true" OnCheckedChanged ="cbREVISION_CheckChanged" />
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
For testing purposes i run a function called SaveRevision and pass a string into it to indicate whether it was checked/unchecked.
public void cbREVISION_CheckChanged(object sender, EventArgs e)
{
CheckBox cb = (CheckBox)sender;
if(cb.Checked)
{
SaveRevision("Checked");
}
else
{
SaveRevision("UnChecked");
}
}
All this function does is display some text on the screen. The literal control is inside a UpdatePanel call UpdatePanelTest.
public void SaveRevision(string myString)
{
DebugLT.Text = DebugLT.Text + myString;
UpdatePanelTest.Update();
}
As I understand how this is setup the OnCheckedChange event should fire each time I click the a checkbox and the string in the DebugLT should grow adding whether the checkbox was checked or not.
The result I get is the intial update to the literal as "Checked". but no matter how many times i click any checkbox in the gridview no values are added to this string or does the string ever include "unchecked".
What do I need to do to be able to capture subsequent clicks?
Aucun commentaire:
Enregistrer un commentaire