Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Conditional checkbox in an editable datagrid

Reply
Thread Tools

Conditional checkbox in an editable datagrid

 
 
shamila.thakur@gmail.com
Guest
Posts: n/a
 
      10-11-2005
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("TextBox1 5");
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid EditItemCommand : must click twice to make DataGrid Editable Diane ASP .Net Datagrid Control 5 11-09-2005 09:54 AM
Including a Data Bound CheckBox in an Editable DataGrid... Alex ASP .Net Datagrid Control 0 10-06-2003 04:53 PM
Including a Data Bound CheckBox in an Editable DataGrid... Alex ASP .Net 0 10-06-2003 04:53 PM
Including a Data Bound CheckBox in an Editable DataGrid... Alex ASP .Net Web Controls 0 10-06-2003 04:53 PM
How do I assign an editable Checkbox in the datagrid JLeary ASP .Net Datagrid Control 2 07-18-2003 03:22 AM



Advertisments