HelpWanted
HelpWanted

Reputation: 71

OnCheckedChanged not being fired on re-population of the form

I have a Gridview that has two buttons Edit & Delete.

On Edit, the row command calls a function called "Populate()" that populates a form located above the grid in a Panel (sets visible = true ).

Problem:

I have a checkbox "cbX", a textbox "txtX", and a dropdownlist "ddlX"(Visible = false)

if cbX is selected => ddlX.Visible = true and txtX.Enabled = false (I have an onCheckChangeed function)

When i chose to edit the entry, in the grid, that originally has cbX.Checked = true I face a problem when the user attempts to uncheck the checkbox. No error is returned it simply does not call the onCheckChanged when I need it to hide the ddlX and Enable the txtX

<asp:TextBox runat="server" ID="txtX" Width="180px"></asp:TextBox>

<asp:CheckBox runat="server" ID="cbX" AutoPostBack="true" Text="Unable to Obtain " OnCheckedChanged="cbX_CheckedChanged" />

<asp:DropDownList runat="server" ID="ddlX" DataTextField="Name" DataValueField="Code" AppendDataBoundItems="True" OnSelectedIndexChanged="ddlX_SelectedIndexChanged" Width="350px" AutoPostBack="true" CausesValidation="true" Enabled="false" Visible="false"></asp:DropDownList>

Upvotes: 0

Views: 37

Answers (1)

HelpWanted
HelpWanted

Reputation: 71

Figured it out. I needed to manually add this:

cbX.CheckedChanged += new EventHandler(this.cbX_CheckedChanged);

in the function that repopulates the form.

Upvotes: 0

Related Questions