Conditional checkbox in an editable datagrid

Discussion in 'ASP .Net Web Controls' started by shamila.thakur@gmail.com, Oct 11, 2005.

  1. Guest

    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.
    , Oct 11, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    0
    Views:
    458
  2. Replies:
    0
    Views:
    389
  3. JLeary

    How do I assign an editable Checkbox in the datagrid

    JLeary, Jul 16, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    161
    Lewis Wang [MSFT]
    Jul 18, 2003
  4. Alex

    Including a Data Bound CheckBox in an Editable DataGrid...

    Alex, Oct 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    128
  5. Alex
    Replies:
    0
    Views:
    141
Loading...

Share This Page