I have a value starttime coming from database which is 12:20PM (for eg)
I want to retrieve it from db and store it to control
<input type="time" name="txtStartTimeHTML" id="txtStartTimeHTML" />
my sp is
Select LTRIM(RIGHT(CONVERT(VARCHAR(20),CAST(A.StdTimeIn as DATETIME)), 7)) as StdTimeIn from TimeMaster
M gettig error that collection is readonly.How to solve this
Retrivin time from db
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Sunny SharmaRank #223 · 11.1K pointsPosted Aug 10, 2013, 2:30 AM EDT
Sunny SharmaRank #223 · 11.1K pointsPosted Aug 9, 2013, 10:12 PM EDT
Seems a coding issue. Can you share your code behind or controller code?
piyusha patravali31 pointsPosted Aug 10, 2013, 1:31 AM EDT
Sunny I am using 3tier architecture so sending code is bit difficult. I have used this code to retrieve value from table when selected from gridview.
the code is
DataSet objDataSet = ob.GetData();
if (objDataSet != null && objDataSet.Tables.Count > 0)
{
Request.Form["txtStartTimeHTML"] = objDataSet.Tables[0].Rows[0]["StdTimeIn"].ToString();
}
Sunny SharmaRank #223 · 11.1K pointsPosted Aug 10, 2013, 1:56 AM EDT
That's enough I needed. The problem is, you're trying to modify a readonly value in Request.Form Collection:
Request.Form["txtStartTimeHTML"] = objDataSet.Tables[0].Rows[0]["StdTimeIn"].ToString();
This will always raise the error that you're having now. Request.Form object contains all the properties of the submitting form and is readonly, so you can not modify this.
Instead, change the Text property of the TextBox like this:
txtStartTimeHTML.Text = objDataSet.Tables[0].Rows[0]["StdTimeIn"].ToString(); // I don't know what is the ID of the textbox so I assume it to be txtStartTimeHTML, change it if it's different.
That's all you need to do.
Happy Coding :)
Cheers!!