Dear All,
Following error encountered while attempting to read dropdown to correspond text box.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.
Source Error:
Line 52:
Line 53: dr1.Read();
Line 54: txtRegRoomNo.Text = dr1["roomno"].ToString();
Line 55: txtRegRate.Text = dr1["rate"].ToString();
Line 56:
Source File: e:\LiveProject\AdminDreamPanel_HMS\Admin\index.aspx.cs Line: 54
Please your valuable guidance and help.
Rgds,
aligahk06

Sachin SinghRank #66 · 26.2K reputationPosted Jan 4, 2022, 11:56 PM EST
Rijwan AnsariRank #82 · 24.2K reputationPosted Jan 5, 2022, 9:58 AM EST
You can check values then do read
example
dr1.Read(); if (dr1.HasRows) { txtRegRoomNo.Text = drl["roomno"].ToString(); txtRegRate.Text = drl["rate"].ToString(); }Nitin SontakkeRank #264 · 9.6K reputationPosted Jan 4, 2022, 12:41 PM EST
Satya KarkiRank #78 · 24.6K reputationPosted Jan 5, 2022, 10:11 AM EST