Giving you a ready sample. Say below is your grid view
<asp:GridView ID="gvM" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkIs" onclick="GetCheckStatus()"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox runat="server" ID="txtId"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField AccessibleHeaderText = "Name" DataField="Name" />
</Columns>
</asp:GridView>
Have a script which will be called every time when the ckeck box is checked or unchecked.
<script language="javascript" type="text/javascript">
function GetCheckStatus() {
var srcControlId = event.srcElement.id;
var targetControlId = event.srcElement.id.replace('chkIs', 'txtId');
if (document.getElementById(srcControlId).checked)
document.getElementById(targetControlId).disabled = false;
else
document.getElementById(targetControlId).disabled = true;
}
</script>
In your aspx.cs page bind the grid with appropriate data source as below.
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
DataRow dr = dt.NewRow();
dr["Name"] = "Das";
dt.Rows.Add(dr);
DataRow dr1 = dt.NewRow();
dr1["Name"] = "Shon";
dt.Rows.Add(dr1);
gvM.DataSource = dt;
gvM.DataBind();
}