Object reference not set to an instance of an object.

  • Thread starter Thread starter yysiow
  • Start date Start date
Y

yysiow

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..
 
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
 
Back
Top