fippif
asked on
How to handle OnCheckedChanged event of a TextBox when TextBox is part of a GridView
I have a gridview (please see attached code).
I want to be able to handle the OnCheckedChanged event of the checkbox within the gridrow as followed:
protected void chk1_CheckChanged(Object sender, EventArgs e)
{
if (ch1.Checked)
txt1.Enabled = false;
else if (!ch1.Checked)
txt1.Enabled = true;
}
Is there a way to make this happen? Thx.
I want to be able to handle the OnCheckedChanged event of the checkbox within the gridrow as followed:
protected void chk1_CheckChanged(Object sender, EventArgs e)
{
if (ch1.Checked)
txt1.Enabled = false;
else if (!ch1.Checked)
txt1.Enabled = true;
}
Is there a way to make this happen? Thx.
<asp:GridView ID="grd" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<table cellspacing="0" cellpadding="0" border="0" style="height: 25px; font-size: 12px;">
<tr style="height: 25px">
<td align="left" style="width: 70px">
check</td>
<td align="left" style="width: 20px">
Text</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellspacing="0" cellpadding="0" border="0" style="height: 25px; width: 600px">
<tr style="height: 25px">
<td align="center"style="width: 70px">
<asp:CheckBox ID="chk1" runat="server" AutoPostBack="true" CausesValidation="false"
OnCheckedChanged="chk1_CheckChanged" />
</td>
<td align="left" style="width: 10px">
<asp:TextBox ID="txt1" runat="server" MaxLength="3" /></td>
</tr>
</table>
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Size="12pt" />
</asp:GridView>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.