我在代码更新命令中出现错误行 [英] I got Error Line in code Update Command

查看:156
本文介绍了我在代码更新命令中出现错误行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的所有专家

Dear All Experts

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"] + "'";



此[e.index]
附近的错误



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

推荐答案

错误提示Controls[0]不是TextBox.您可以调试并查看单元格中有多少个控件,甚至可以通过ID/名称找到该控件.
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.


这篇关于我在代码更新命令中出现错误行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆