Ameya Deshpande

Ameya Deshpande

  • NA
  • 28
  • 6.2k

IndexOutofRangeException :There is no row at position 0

Jul 23 2017 9:13 AM

I am getting the following error when I click on the login button:

There is no row at position 0

Specifically from the Image3.ImageUrl = HDT.Rows[0]["image"].ToString(); line.

 
 
DS_HOUSE.HOUSE_SELECTDataTable HDT = new DS_HOUSE.HOUSE_SELECTDataTable();
DS_HOUSETableAdapters.HOUSE_SELECTTableAdapter HAdapter = new DS_HOUSETableAdapters.HOUSE_SELECTTableAdapter();
DS_USER.USERMST_SELECTDataTable UDT = new DS_USER.USERMST_SELECTDataTable();
DS_USERTableAdapters.USERMST_SELECTTableAdapter UAdapter = new DS_USERTableAdapters.USERMST_SELECTTableAdapter();
     
protected void Page_Load(object sender, EventArgs e)
   {
       lblsell.Text = "";
UDT = UAdapter.Select_By_UID(Convert.ToInt32(Session["uid"].ToString()));
HDT = HAdapter.Select_By_SNAME_BLOCKNO(UDT.Rows[0]["societyname"].ToString(), Convert.ToInt32(UDT.Rows[0]["Houseid"].ToString()));
Image3.ImageUrl = HDT.Rows[0]["image"].ToString();
lblsname.Text = HDT.Rows[0]["sname"].ToString();
lblbno.Text = HDT.Rows[0]["blockno"].ToString();
lbltype.Text = HDT.Rows[0]["type"].ToString();
ViewState["HID"] = HDT.Rows[0]["HID"].ToString();
}
 
 The table is not empty and yet this error is coming.Please help.
 The full project source code and database backup has been attached.
It would be great help if you run and help solving this error which is bugging me since long time now. 

Answers (8)