请教一个问题 有增加和保存两个按钮,点击增加则textbox增加 即又出现另一个textbox而再点击也是出现一样 而且输入数据保存可以到数据库中 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 protected void Page_Load(object sender, EventArgs e) { if (Session["tb"] != null) { List<TextBox> list = Session["tb"] as List<TextBox>; foreach (TextBox tb in list) this.form1.Controls.Add(tb); } } protected void btnAdd_Click(object sender, EventArgs e) { List<TextBox> list = new List<TextBox>(); if (Session["tb"] != null) list = Session["tb"] as List<TextBox>; TextBox tb = new TextBox(); tb.ID = "TextBox" + (list.Count + 1).ToString(); tb.Text = tb.ID; list.Add(tb); Session["tb"] = list; foreach (TextBox textbox in list) this.form1.Controls.Add(tb); } protected void btnSave_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection("连接字符串")) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "insert into table values('" + (this.FindControl("TextBox1") as TextBox).Text + "','" + …………… (this.FindControl("TextBoxn") as TextBox).Text + "')"; cmd.ExecuteNonQuery(); } } 伪静态发布后的问题(在线等,跟帖有分) 从xml获取出具进行绑定 正则表达式含义 建站需要注意哪些?? ScriptManager 使用问题 急………… 在线等候 点击button刷新后 textbox会变小 js中如何得到当前时间的天数? 请问各位高手,UserControl可以当作参数在.cs的类文件的方法中传递吗,谢谢了 将Word文档转换成pdf时候出错 如何取dataset中的字段的值(等待...) confirm里面怎么绑定<%#Eval("name")%>这个数据?谢谢指教 e.Item.Cells[0].Text与e.Item.Cells[1].Controls[0])区别
protected void Page_Load(object sender, EventArgs e)
{
if (Session["tb"] != null)
{
List<TextBox> list = Session["tb"] as List<TextBox>;
foreach (TextBox tb in list)
this.form1.Controls.Add(tb);
}
} protected void btnAdd_Click(object sender, EventArgs e)
{
List<TextBox> list = new List<TextBox>(); if (Session["tb"] != null)
list = Session["tb"] as List<TextBox>; TextBox tb = new TextBox();
tb.ID = "TextBox" + (list.Count + 1).ToString();
tb.Text = tb.ID; list.Add(tb);
Session["tb"] = list;
foreach (TextBox textbox in list)
this.form1.Controls.Add(tb);
} protected void btnSave_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection("连接字符串"))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "insert into table values('" +
(this.FindControl("TextBox1") as TextBox).Text + "','" +
……………
(this.FindControl("TextBoxn") as TextBox).Text + "')";
cmd.ExecuteNonQuery();
}
}