Problem is here-
s1 += ds1.Tables["imagepath"].Rows[0][0].ToString();
s1 += " ";
s1 += ds1.Tables["imagepath"].Rows[1][0].ToString();
s1 += " ";
s1 += ds1.Tables["imagepath"].Rows[2][0].ToString();
You need to put checks on data existance before accesing them.
Try this-
if(ds1.Tables["imagepath"].Rows.Count>0)
{
s1 += ds1.Tables["imagepath"].Rows[0][0].ToString();
}
s1 += " ";
if(ds1.Tables["imagepath"].Rows.Count>1)
{
s1 += ds1.Tables["imagepath"].Rows[1][0].ToString();
}
s1 += " ";
if(ds1.Tables["imagepath"].Rows.Count>2)
{
s1 += ds1.Tables["imagepath"].Rows[2][0].ToString();
}
Hope, it helps :)