我创建了两个动态表和文本框,如下所示:
protected void drpNetworkList_SelectedIndexChanged(object sender, EventArgs e)
{
string socialNetworkName = drpNetworkList.SelectedItem.Text;
DataSet networkdata = VoCServiceObj.GetSocailNetworkNameDetails(partnerid,socialNetworkName);
int cdount = networkdata.Tables[0].Rows.Count;
pnlViewData.Controls.Clear();
Check.Checked = true;
pnlViewData.Visible = true;
table = new Table();
table.ID = "tbl_dy";
//Brandurl
row = new TableRow();
cell = new TableCell();
Label lbl = new Label();
lbl.ID = "lbl_1";
lbl.Text = "BrandURL";
cell.Controls.Add(lbl);
row.Cells.Add(cell);
cell = new TableCell();
TextBox txt = new TextBox();
txt.ID = "textBox";
txt.Text = networkdata.Tables[0].Rows[0]["BrandDestinationURL"].ToString();
cell.Controls.Add(txt);
row.Cells.Add(cell);
table.Rows.Add(row);
for (int i = 1; i <= cdount; i++)
{
int count = i - 1;
//ProdutId
row = new TableRow();
cell = new TableCell();
Label lbl2 = new Label();
lbl2.ID = "lbl_1'" + i + "'";
lbl2.Text = "ProductID" + i + "'";
cell.Controls.Add(lbl2);
row.Cells.Add(cell);
cell = new TableCell();
TextBox txt2 = new TextBox();
txt2.ID = "textBox1" + i + "'";
txt2.Text = networkdata.Tables[0].Rows[count]["ProductID"].ToString();
cell.Controls.Add(txt2);
row.Cells.Add(cell);
table.Rows.Add(row);
//ProdutURL
row = new TableRow();
cell = new TableCell();
Label lbl3 = new Label();
lbl3.ID = "lbl_2'" + i + "'";
lbl3.Text = "ProductURL" + i + "'";
cell.Controls.Add(lbl3);
row.Cells.Add(cell);
cell = new TableCell();
TextBox txt3 = new TextBox();
txt3.ID = "textBox2" + i + "'";
txt3.Text = networkdata.Tables[0].Rows[count]["ProductDestinationURL"].ToString();
cell.Controls.Add(txt3);
row.Cells.Add(cell);
table.Rows.Add(row);
}
pnlViewData.Controls.Add(table);
}
protected void imgSave_Click(object sender, ImageClickEventArgs e)
{
TextBox tb1 = (TextBox)Page.FindControl("textBox11");
String str = string.Empty;
str = tb1.Text;
}
文本框显示来自数据库的默认值。我在运行时编辑这些值,我想在按钮单击函数中获取这些值。我如何做到这一点???
提前致谢!!