在HTML中,指定DropDownList的数据源是哪个函数提供:
<asp:TemplateColumn HeaderText="发送人">
<ItemTemplate>
<asp:Label id=lblMan runat="server" Width="88px" Text='<%#DataBinder.Eval(Container,"DataItem.DManCode") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList id=dplMan2 runat="server" Width="88px" Datasource="<%#DplDatasource()%>"
DataValueField="ManCode" DataTextField="ManName" Enabled="true" AutoPostBack="True">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
<ItemTemplate>

</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList id=dplMan2 runat="server" Width="88px" Datasource="<%#DplDatasource()%>"
DataValueField="ManCode" DataTextField="ManName" Enabled="true" AutoPostBack="True">


</asp:TemplateColumn>
同时在对应的C#文件中,实现DplDatasource()方法:
1
protected DataSet DplDatasource()
2
{
3
DeliveryManBLL dmanBll = new DeliveryManBLL();
4
ArrayList availlist = dmanBll.GetAvailMan();
5
DataTable tb = new DataTable();
6
tb.Columns.Add("ManCode",typeof(string));
7
tb.Columns.Add("ManName",typeof(string));
8
DataRow dr = tb.NewRow();
9
dr[0] = "";
10
dr[1] = "";
11
tb.Rows.Add(dr);
12
for(int i=0;i<availlist.Count;i++)
13
{
14
dr = tb.NewRow();
15
dr[0] = ((DeliveryManInfo)availlist[i]).ManCode;
16
dr[1] = ((DeliveryManInfo)availlist[i]).ManName;
17
tb.Rows.Add(dr);
18
}
19
DataSet dset = new DataSet();
20
dset.Tables.Add(tb);
21
return dset;
22
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22
