<asp:datalist id="Datalist1" runat="server" DataKeyField="id" ExtractTemplateRows="True" HorizontalAlign="Center" Width="100%" GridLines="Both" BorderWidth="1px">
<HeaderTemplate>
<Asp:Table Runat="Server" Width="760" ID="Table3">
<Asp:TableRow Runat="Server" HorizontalAlign="Center" ID="Tablerow3">
<Asp:TableCell Runat="Server" ID="Tablecell13">序</Asp:TableCell>
<Asp:TableCell Runat="Server" ID="Tablecell17">责任部门</Asp:TableCell>
<Asp:TableCell Runat="Server" ID="Tablecell18">车间</Asp:TableCell>
</Asp:TableRow>
</Asp:Table>
</HeaderTemplate>
<ItemTemplate>
<Asp:Table Runat="Server" ID="Table4">
<Asp:TableRow Runat="Server" HorizontalAlign="Center" ID="Tablerow4">
<Asp:TableCell Runat="Server" ID="Tablecell22">
<Asp:Label Runat="server" ID="txtNos"></Asp:Label>
</Asp:TableCell>
<Asp:TableCell Runat="Server" ID="Tablecell25">
<asp:DropDownList id="DropDownList1" runat="server">
</asp:DropDownList>
</Asp:TableCell>
<Asp:TableCell Runat="Server" ID="Tablecell26">
<asp:DropDownList id="Dropdownlist2" runat="server"></asp:DropDownList>
</Asp:TableCell>
</Asp:TableRow>
</Asp:Table>
</asp:datalist>
如代码中的DropDownlist怎样和一个数据库表的字段绑定?
<HeaderTemplate>
<Asp:Table Runat="Server" Width="760" ID="Table3">
<Asp:TableRow Runat="Server" HorizontalAlign="Center" ID="Tablerow3">
<Asp:TableCell Runat="Server" ID="Tablecell13">序</Asp:TableCell>
<Asp:TableCell Runat="Server" ID="Tablecell17">责任部门</Asp:TableCell>
<Asp:TableCell Runat="Server" ID="Tablecell18">车间</Asp:TableCell>
</Asp:TableRow>
</Asp:Table>
</HeaderTemplate>
<ItemTemplate>
<Asp:Table Runat="Server" ID="Table4">
<Asp:TableRow Runat="Server" HorizontalAlign="Center" ID="Tablerow4">
<Asp:TableCell Runat="Server" ID="Tablecell22">
<Asp:Label Runat="server" ID="txtNos"></Asp:Label>
</Asp:TableCell>
<Asp:TableCell Runat="Server" ID="Tablecell25">
<asp:DropDownList id="DropDownList1" runat="server">
</asp:DropDownList>
</Asp:TableCell>
<Asp:TableCell Runat="Server" ID="Tablecell26">
<asp:DropDownList id="Dropdownlist2" runat="server"></asp:DropDownList>
</Asp:TableCell>
</Asp:TableRow>
</Asp:Table>
</asp:datalist>
如代码中的DropDownlist怎样和一个数据库表的字段绑定?
找到这个dropdownlist然后就可以绑定了
<asp:DropDownList DataTextField="mc" DataValueField="lsh"
DataSource='<%# GetSource() %>' id=ddl_yplx runat="server" Width="100%"
SelectedValue='<%# DataBinder.Eval(Container, "DataItem.type") %>'>
</asp:DropDownList>
后台:
protected DataSet GetSource()
{
return [数据集];
}
--------------------------------------------------------
SelectedValue='<%# DataBinder.Eval(Container, "DataItem.type") %>'
也可以:
SelectedValue='<%# Container.DataItem("YourField") %>'
--------------------------------------------------------
this.DDL.DataSource=ds;
this.DDL.DataBind();
this.DDL.DataTextField="字段";
this.DDL.DataValueField="字段";