我正在中继器中加载下拉菜单,但我看不到中继器。为什么我看不到它?
aspx:
<asp:Repeater ID="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound">
<ItemTemplate>
<table>
<tr>
<td>
<asp:DropDownList ID="DropDownList1" 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="DropDownList6" runat="server"> </asp:DropDownList>
代码隐藏:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DataTable dt = new DataTable();
dt = Common.LoadExample();
DropDownList ddl = (DropDownList)e.Item.FindControl("DropDownList6") ;
ddl.DataSource = dt;
ddl.DataTextField = "Name";
ddl.DataValueField = "Name";
ddl.DataBind();
}
// 用于加载的数据表
public static DataTable LoadExample()
{
DBAccess objDBAccess = new DBAccess();
DataTable dt = new DataTable();
try
{
objDBAccess.AddParameter("@Name", SqlDbType.VarChar);
dt = objDBAccess.ExecuteDataTable("usp_test");
return dt;
}
catch
{
return null;
}
}