如何给动态生成的 DropDownList 绑定数据,如何给"txtBuyer" + i绑定数据?code=csharp] tc = new TableCell();
tl = new DropDownList();
tl.CssClass = "FieldStyle";
tl.ID = "txtBuyer" + i;
tc.Controls.Add(tl);
tr.Cells.Add(tc);[[/code]
tl = new DropDownList();
tl.CssClass = "FieldStyle";
tl.ID = "txtBuyer" + i;
tc.Controls.Add(tl);
tr.Cells.Add(tc);[[/code]
不懂,我要把数据 tBuyer 绑定在DropDownList里。
<asp:DropDownList ID="ddl" DataValueField="T" runat="server"></asp:DropDownList>
后台
ddl.DataSource = datatable(从数据库中得到的数据,必须有字段T)
<asp:DropDownList ID="ddl" DataValueField="T" runat="server"></asp:DropDownList>
后台
ddl.DataSource = datatable(从数据库中得到的数据,必须有字段T)
ddl.DataBind();
ddl.Items.Insert(0, new ListItem("请选择", "-1"));
ddl.DataTextField = "textfield";
ddl.DataValueField = "valuefield";
tl = new DropDownList();
tl.DataSource = 数据源
tl.DataTextField = "显示";
tl.DataValueField = "值";
tc.Controls.Add(tl);
...