本人做程序时出现的问题,语言C#
详细代码如下for(inti=0;i<=4;i++){modelZiChan.nianFen=DateTime.Now.Year-i;modelZiChan.zongZi...
详细代码如下
for (int i = 0; i <= 4; i++)
{
modelZiChan.nianFen = DateTime.Now.Year - i;
modelZiChan.zongZiChan = ((TextBox)FindControl("zongZiChan" + i)).Text;
modelZiChan.zongFuZhai = ((TextBox)FindControl("zongFuZhai" + i)).Text;
modelZiChan.fuZhaiLv = ((TextBox)FindControl("fuZhaiLv" + i)).Text;
modelZiChan.yeWuShouRu = ((TextBox)FindControl("yeWuShouRu" + i)).Text;
modelZiChan.jingLiRun = ((TextBox)FindControl("jingLiRun" + i)).Text;
modelZiChan.guDingZiChan = ((TextBox)FindControl("guDingZiChan" + i)).Text;
modelZiChan.liuDongZiChan = ((TextBox)FindControl("liuDongZiChan" + i)).Text;
modelZiChan.jingZiChan = ((TextBox)FindControl("jingZiChan" + i)).Text;
modelZiChan.xiangMuId = XiangMuID;
if (bllZiChan.Add(modelZiChan) > 0)
{ }
else
{
Response.Write("<script>alert('系统信息:企业资产添加出现错误,请查证重新添加企业资产!');location='AddXiangMu.aspx';</script>");
}
}
报错如下:
无法将类型为“System.Web.UI.HtmlControls.HtmlInputText”的对象强制转换为类型“System.Web.UI.WebControls.TextBox”。 展开
for (int i = 0; i <= 4; i++)
{
modelZiChan.nianFen = DateTime.Now.Year - i;
modelZiChan.zongZiChan = ((TextBox)FindControl("zongZiChan" + i)).Text;
modelZiChan.zongFuZhai = ((TextBox)FindControl("zongFuZhai" + i)).Text;
modelZiChan.fuZhaiLv = ((TextBox)FindControl("fuZhaiLv" + i)).Text;
modelZiChan.yeWuShouRu = ((TextBox)FindControl("yeWuShouRu" + i)).Text;
modelZiChan.jingLiRun = ((TextBox)FindControl("jingLiRun" + i)).Text;
modelZiChan.guDingZiChan = ((TextBox)FindControl("guDingZiChan" + i)).Text;
modelZiChan.liuDongZiChan = ((TextBox)FindControl("liuDongZiChan" + i)).Text;
modelZiChan.jingZiChan = ((TextBox)FindControl("jingZiChan" + i)).Text;
modelZiChan.xiangMuId = XiangMuID;
if (bllZiChan.Add(modelZiChan) > 0)
{ }
else
{
Response.Write("<script>alert('系统信息:企业资产添加出现错误,请查证重新添加企业资产!');location='AddXiangMu.aspx';</script>");
}
}
报错如下:
无法将类型为“System.Web.UI.HtmlControls.HtmlInputText”的对象强制转换为类型“System.Web.UI.WebControls.TextBox”。 展开
2个回答
展开全部
类型转换错误,说明你其中有HtmlInputText控件,而它是不能被强转为TextBox类型的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询