Object reference not set to an instance of an object.

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..
 
K

Kevin Spencer

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
 

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

Top