I have 1 gridview. and every row is editable and after checkbox checked i want to enable textbox otherwise this textbox is disable. How to do this...
thanks in advance
How to disable textbox after checkbox checked in datagridview
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Deepak SharmaRank #541 · 4.5K reputationPosted Feb 7, 2012, 12:40 AM EST
protected void CheckBox1_OnCheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
TextBox txt = (TextBox)GridView1.Rows[i].Cells[0].FindControl("TextBox1");
if (cb.Checked)
{
txt.Enabled = true;
}
else
{
txt.Enabled = false;
}
}
}
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 7, 2012, 5:48 PM EST
you can also use java script/ Jquery to disable textbox.
$(
"#SeasonId").attr("disabled", "disabled");