读取动态生成的Table中的textbox输入数据,然后把数据加到sql数据库中 数据库SQLtextbox添加数据asp.net 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 问题是我要怎么获取生成的textbox的ID? "我要怎么获取生成的textbox的ID? "这个可以直接设置吧 亲 textbox动态生成,没法设置他的ID啊。难道ID就是 textbox1 textbox2这样连续生成下去的? TextBox tb = new TextBox(); tb.ID = "txtTest"; textbox动态生成,没法设置他的ID啊。难道ID就是 textbox1 textbox2这样连续生成下去的?你给textbox的ID自动连续生成就像textbox1 textbox2 textbox动态生成,没法设置他的ID啊。难道ID就是 textbox1 textbox2这样连续生成下去的?你给textbox的ID自动连续生成就像textbox1 textbox2在用 Request.Form["textbox1"]来获取文本里的值 CreateTableRow() 你就不能在这个方法里传个序号什么的作为id 么?CreateTableRow(int index) 然后每个textbox 的id 后缀 可以使用这个序号“text_”+index foreach (TableRow row in Table2.Rows) { int i = 0; i++; a = "insert into GongshiTongji(序号,用工部门,用工岗位,学号,姓名,工时,酬金,学院,专业班级)values('" + i.ToString() + "','" + (Table2.FindControl("Bbumen"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bgangwei"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bxuehao"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bxingming"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bgongshi"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bchoujin"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bxueyuan"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bbanji"+i.ToString()) as TextBox).Text + "')"; }这个是插入语句,提示 未将对象引用设置到对象的实例 void CreateTableRow(int index) { TableRow tbleRow = new TableRow(); TableCell tbleCell = new TableCell(); tbleCell.Controls.Add(new LiteralControl(Table2.Rows.Count.ToString())); tbleRow.Cells.Add(tbleCell); tbleCell = new TableCell(); TextBox Bxingming = new TextBox(); Bxingming.Style[HtmlTextWriterStyle.Width] = "88px"; //这里可以给textbox的id 赋值 Bxingming.ID = "Bm_"+ index; ..............//其他的textbox都可以按照这种方式给id 赋值,注意要唯一性 } 这个问题没有解决呀,我也遇到这样的问题,动态生成ID没问题,但取ID和ID值却没有办法实现。 委托触发 一个取值问题,谢谢! “转到定义”为什么不能用 请教用visualstudio.net建asp.net项目时遇到的问题。 请教高手一个问题 在asp.net中如何通过sock连接数据库 关于asp.net自定义错误的问题 jquery+ajax 不执行 Calendar控件问题,请多多指教 画图的问题,大家帮帮忙,给点思路,很着急呀~~~~ 关于CSS,JS文件缓存与ETAG问题 submit提交file表单,服务端不读取file,如何立刻响应客户端
textbox动态生成,没法设置他的ID啊。难道ID就是 textbox1 textbox2这样连续生成下去的?
tb.ID = "txtTest";
textbox动态生成,没法设置他的ID啊。难道ID就是 textbox1 textbox2这样连续生成下去的?你给textbox的ID自动连续生成就像textbox1 textbox2
textbox动态生成,没法设置他的ID啊。难道ID就是 textbox1 textbox2这样连续生成下去的?你给textbox的ID自动连续生成就像textbox1 textbox2在用 Request.Form["textbox1"]来获取文本里的值
然后每个textbox 的id 后缀 可以使用这个序号“text_”+index
{
int i = 0;
i++;
a = "insert into GongshiTongji(序号,用工部门,用工岗位,学号,姓名,工时,酬金,学院,专业班级)values('" + i.ToString() + "','" + (Table2.FindControl("Bbumen"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bgangwei"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bxuehao"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bxingming"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bgongshi"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bchoujin"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bxueyuan"+i.ToString()) as TextBox).Text + "','" + (Table2.FindControl("Bbanji"+i.ToString()) as TextBox).Text + "')";
}
这个是插入语句,提示 未将对象引用设置到对象的实例
void CreateTableRow(int index)
{
TableRow tbleRow = new TableRow();
TableCell tbleCell = new TableCell();
tbleCell.Controls.Add(new LiteralControl(Table2.Rows.Count.ToString())); tbleRow.Cells.Add(tbleCell);
tbleCell = new TableCell();
TextBox Bxingming = new TextBox();
Bxingming.Style[HtmlTextWriterStyle.Width] = "88px";
//这里可以给textbox的id 赋值
Bxingming.ID = "Bm_"+ index;
..............
//其他的textbox都可以按照这种方式给id 赋值,注意要唯一性
}