如何使用asp.net和C#.how存储数据库创建动态文本框。请任何人帮助我,我是新手。谢谢提前
答案 0 :(得分:1)
我希望这可以帮到你: 对于数据访问,您可以在这里查看: 1. http://www.asp.net/web-forms 2.下载“Professional Asp.Net 4(wrox)”或“Microsoft ASP.NET 4 Step by Step”
在gridview中添加文本框(在本例中)的代码就像这样
void addTextBoxInGridView()
{
int nr = 0, nc = 0;
nr = this.GridView1.Rows.Count;
if (nr > 0)
{
nc = this.GridView1.HeaderRow.Cells.Count;
int r = 0, c = 0;
for (r = 0; r < nr; r++)
{
for (c = 0; c < nc; c++)
{
string v1 = "";
v1 = HttpUtility.HtmlDecode(this.GridView1.Rows[r].Cells[c].Text.ToString());
TextBox textbox = new TextBox();
textbox.Text = v1;
textbox.EnableViewState = true;
textbox.Style["text-align"] = "center";
textbox.Width = 40;
textbox.ID = "txt" + Convert.ToString(r) + Convert.ToString(c);
this.GridView1.Rows[r].Cells[c].Controls.Add(textbox);
}
}
}
}
快乐代码!!
答案 1 :(得分:0)