Object reference not set to an instance of an object.

Discussion in 'ASP .Net' started by yysiow, Jul 12, 2003.

  1. yysiow

    yysiow Guest

    hi, help..

    protected void Item_Click(object sender, DataGridCommandEventArgs e)
    {
    if(((LinkButton)e.CommandSource).CommandName == "SelectItem")
    {
    string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();

    try
    {
    DataRow dr = ds1.tblPlasmaInfomation.FindByPlasmaid(Int32.Parse(key));
    lbccuname.Text = dr["Plasma_ccuname"].ToString();
    }
    catch(Exception exc)
    {
    TextBox1.Text = exc.Message;
    }
    }

    }



    i step by step run..and dr always null....how can i sol this
    problem..thanks..
     
    yysiow, Jul 12, 2003
    #1
    1. Advertising

  2. If you can step through it, you can do some Quick Watches as well. You need
    to find out what you're getting back with the line of code that assigns a
    value to the "key" variable, since obvioulsy you're not getting anything
    back when you use it to find your DataRow.

    --
    HTH,

    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    http://www.takempis.com
    Big things are made up
    of lots of little things

    "yysiow" <> wrote in message
    news:...
    > hi, help..
    >
    > protected void Item_Click(object sender, DataGridCommandEventArgs e)
    > {
    > if(((LinkButton)e.CommandSource).CommandName == "SelectItem")
    > {
    > string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
    >
    > try
    > {
    > DataRow dr =

    ds1.tblPlasmaInfomation.FindByPlasmaid(Int32.Parse(key));
    > lbccuname.Text = dr["Plasma_ccuname"].ToString();
    > }
    > catch(Exception exc)
    > {
    > TextBox1.Text = exc.Message;
    > }
    > }
    >
    > }
    >
    >
    >
    > i step by step run..and dr always null....how can i sol this
    > problem..thanks..
    >
    >
     
    Kevin Spencer, Jul 12, 2003
    #2
    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. Parthiv Joshi
    Replies:
    2
    Views:
    695
    Kalyan
    Jul 2, 2004
  2. Suresh Kojhani
    Replies:
    1
    Views:
    2,388
    Anushi
    Jul 29, 2004
  3. Chris Fink
    Replies:
    2
    Views:
    4,095
    David Waz...
    Jul 3, 2003
  4. Tim
    Replies:
    1
    Views:
    497
    Bill Priess
    Jul 17, 2003
  5. Replies:
    1
    Views:
    482
    Mark Rae [MVP]
    Sep 20, 2007
Loading...

Share This Page