Conditional checkbox in an editable datagrid

S

shamila.thakur

I have a checkbox and a textbox in an editable datagrid.
The textbox.visible property is set to false initially.
But wen the checkbox is checked i want it to become true.
outside the datagrid, i used the _CheckedChangedEvent of the checkbox.


protected void ItemCreatedEventHandler_DataGrid3(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item ||
e.Item.ItemType==ListItemType.AlternatingItem)
{
CheckBox cBox = (CheckBox)e.Item.FindControl("CheckBox1");
cBox.CheckedChanged += new EventHandler(OnChangeHandler);
}
}

protected void OnChangeHandler(object sender,System.EventArgs e)
{
CheckBox chk = (CheckBox)sender;
TextBox txt = (TextBox)chk.NamingContainer.FindControl("TextBox15");
Label lbl = (Label)chk.NamingContainer.FindControl("lblMaxUses");
if(chk.Checked)
{
txt.Visible=true;
lbl.Visible=false;
}
}

But it gives me an error on line
cBox.CheckedChanged += new EventHandler(OnChangeHandler);

Object reference not set to an instance of an object

cBox is null.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top