我在DropDownList
中继器内绑定了一个,下面是我的标记
<asp:Repeater ID="Repeater2" runat="server"
onitemdatabound="Repeater2_ItemDataBound">
<HeaderTemplate>
<asp:DropDownList ID="DropDownList8" runat="server">
<asp:ListItem>Select</asp:ListItem>
<asp:ListItem>Left</asp:ListItem>
<asp:ListItem>Right</asp:ListItem>
<asp:ListItem>SubString</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList7" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Button" />
</HeaderTemplate>
<FooterTemplate>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:Repeater>
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
try
{
if (e.Item.ItemType == ListItemType.Header)
{
DataTable dt = new DataTable();
dt = Common.LoadExample();
DropDownList ddl = (DropDownList)e.Item.FindControl("DropDownList2");
ddl.DataSource = dt;
ddl.DataTextField = "Name";
ddl.DataValueField = "Name";
}
}
catch (Exception ex)
{
throw;
}
}
但我无法填写下拉列表,因为断点e.Item.ItemType == ListItemType.Header
在这里跳过。我该如何解决这个问题?