There is no row at position 0.

Posted by Shitalsalve under ASP.NET on 12/17/2012 | Points: 10 | Views : 2324 | Status : [Member] | Replies : 1
hello i got this error there is no row position
i want 2 check null values from db
my code is here
try
{


DataSet ds = new DataSet();
List<string> para = new List<string>();
para.Add(txt_empid.Text);
ds = bl_obj.blFillGrid_WithParameter("sp_showempname", para);

if (ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count >= 0)
{

if (ds.Tables[0].Rows[0][0].ToString()==null)
{
lbl_msg.Text = "Record not available";
}
else
{
lbl_msg.Text = "Record Available";
}
}

}


txt_Empname.Text = ds.Tables[0].Rows[0][0].ToString();

}
catch (Exception eX)
{



}
plz help me for this




Responses

Posted by: Ranjeet_8 on: 12/17/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
try this,

try{
DataSet ds = new DataSet();
List<string> para = new List<string>();
para.Add(txt_empid.Text);
ds = bl_obj.blFillGrid_WithParameter("sp_showempname", para);
if (ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0][0].ToString() == null || ds.Tables[0].Rows[0][0].ToString().Trim() =="" )
{
lbl_msg.Text = "Record not available";
}
else
{
lbl_msg.Text = "Record Available";
}
txt_Empname.Text = ds.Tables[0].Rows[0][0].ToString();
}
}
}
catch (Exception eX)
{ lbl_msg.Text = "Error"; }


Shitalsalve, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response