asp.net 绑定的文本框如何设置默认值 formview模版内的文本框,绑定了数据源,请问如何设置默认值?还有怎么赋值? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 formView有三种状态!下面是在插入状态时对id为TextBox1进行赋值: protected void FormView1_DataBound(object sender, EventArgs e) { if (FormView1.CurrentMode == FormViewMode.Insert) { TextBox t1 = FormView1.FindControl("TextBox1") as TextBox; t1.Text = "aaa"; } } 我用的VB这样If FormView1.CurrentMode = FormViewMode.Insert Then Dim t1 As TextBox = FormView1.FindControl("aaiTextBox") t1.Text = "aaaa"End If会报错“未将对象引用设置到对象的实例。” 应该是没有找到id为aaiTextBox的控件,你可以string str = FormView1.FindControl("aaiTextBox").class 打断点看看是结果是什么。 protected void FormView1_DataBound(object sender, EventArgs e) { if(FormView1.CurrentMode==FormViewMode.Insert) { TextBox txt1=FormView1.FindControl( "TextBox1 ") as TextBox; txt1.Text=""; } }是否为null 以实验DataBound事件无法找到控件,要在load或 商城系统是怎么样做,怎么样规划的?特别是支付部分... ASP.NET Make a TimeTable(C#) 关于DateTime.Now.ToLongDateString()的一个怪异现象 读取sitemapnode的roles属性的值 一个关于fckeditor的问题,用过的高手帮帮忙。 如何限制TextBox中输入中文的个数呀? 文章的评论模块写好了,希望大家帮测试一下。 http://www.qq166.com/vip.htm?qq=998825,这个是病毒地址吗? 晕搞晕了。还是框架问题 打开一个新框架,并显示一个新页 请各位帮帮吗。 急~~~~~~~进者有分 游标变量!
protected void FormView1_DataBound(object sender, EventArgs e)
{
if (FormView1.CurrentMode == FormViewMode.Insert)
{
TextBox t1 = FormView1.FindControl("TextBox1") as TextBox;
t1.Text = "aaa";
}
}
If FormView1.CurrentMode = FormViewMode.Insert Then
Dim t1 As TextBox = FormView1.FindControl("aaiTextBox")
t1.Text = "aaaa"
End If
会报错“未将对象引用设置到对象的实例。”
{
if(FormView1.CurrentMode==FormViewMode.Insert)
{
TextBox txt1=FormView1.FindControl( "TextBox1 ") as TextBox;
txt1.Text="";
}
}是否为null