Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All Experts

C#
string query = "update Questionnaire_UserAnswers set Comments='" + (TextBox)grdView.Rows[0].Cells[e.index].Controls[0] + "', Marks=" + (TextBox)grdView.Rows[4].Cells[e.index].Controls[0] + " where Question_ID=" + (TextBox)grdView.Rows[0].Cells[e.index].Controls[0] + "UserName='" + Request.QueryString["UserName"] + "'";


Error near In this [e.index]

correct the update command

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'.

thanks for valuable replay
Posted
Updated 9-Nov-11 19:31pm
v2

1 solution

As the error says Controls[0] is not TextBox. You can debug and look how many controls does the cell have, or even find the control by id/name.
 
Share this answer
 
Comments
2011999 10-Nov-11 2:05am    
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
2011999 10-Nov-11 2:05am    
Error Message

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900