无法将类型“string”隐式转换为“System.Web.UI.WebControls.TextBox”

转帖1:
错误 1 无法将类型“string”隐式转换为“System.Web.UI.WebControls.TextBox” E://network center//admin//AddInformation.aspx 1
为什么出现这个错误
--------------------------------------------------------------------------------
ojlovecd»
贴出错代码
--------------------------------------------------------------------------------
ojlovecd»
估计是你的TextBox后面忘了打.Text了
--------------------------------------------------------------------------------
jt9079»
同意楼上的。.
string 是不能直接赋值给 TextBox 的..
TextBox是控件...
string 只能赋值给 TextBox的Text属性...
如:
  TextBox.Text = "aaaaa";
--------------------------------------------------------------------------------
shunxin2008»
同意楼上说的
--------------------------------------------------------------------------------
shunxin2008»
或者是
string str=TextBox.Text;
就可以了
--------------------------------------------------------------------------------
billclinton8»
同意2和3楼的看法
--------------------------------------------------------------------------------
peng_weida»
同意6楼的说法!
--------------------------------------------------------------------------------
mulpig»
估计是你的TextBox后面忘了打.Text了
嗯嗯
--------------------------------------------------------------------------------
beancurd005»
System.Web.UI.WebControls.TextBox 的类型是TextBox
转换为String类型肯定会报错的
欲取值,加上.Text();
 
 
转帖2:
System.Web.UI.WebControls.TextBox是什么意思啊?
在数据库中用户信息表的密码列显示System.Web.UI.WebControls.TextBox又是怎么一回事啊?
最佳答案
因为你把控件名当成里面输入的数据传到数据库里去了。
应该是
sqlcommond cmd =new sqlcommond("insert into a values '"+this.textbox1.text+"'");
然后执行这条语句就可以了。
转帖3: 
ASP.NET初始化页面就出错,求助
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) {
            this.txtLoginName = "";
            this.txtPassword = "";
            this.txtName = "";
            this.txtAge = "";
            this.txtAddress = "";
        }
    }

编译时报:错误 1 无法将类型“string”隐式转换为“System.Web.UI.WebControls.TextBox” C:/Documents and Settings/jms/My Documents/Visual Studio 2005/WebSites/WebSite1/Default.aspx.cs 21 33 C:/.../WebSite1/
的错,怎么修改?
最佳答案
赋值错了吧!
应该是:
this.txtLoginName.Text="";
下面类似!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值