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
"yysiow" <yysiow@.ytlesolutions.com> wrote in message
news:OAcRLlCSDHA.212@.TK2MSFTNGP10.phx.gbl...
> 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
"yysiow" <yysiow@.ytlesolutions.com> wrote in message
news:OAcRLlCSDHA.212@.TK2MSFTNGP10.phx.gbl...
> 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..
Thursday, March 22, 2012
Object reference not set to an instance of an object.
Labels:
asp,
commandname,
commandsource,
datagridcommandeventargs,
instance,
item_click,
linkbutton,
net,
object,
protected,
reference,
selectitem,
string,
void
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment