C# 如何在中继器中动态地将dropdownlist添加到特定行
我想在asp.net c中将dropdownlist添加到中继器# 我想在单击选择座位(如redbus.in)时显示登机点的下拉列表 怎么做C# 如何在中继器中动态地将dropdownlist添加到特定行,c#,asp.net,asprepeater,C#,Asp.net,Asprepeater,我想在asp.net c中将dropdownlist添加到中继器# 我想在单击选择座位(如redbus.in)时显示登机点的下拉列表 怎么做 <asp:Repeater ID="rptItemsInCart" OnItemDataBound="rptItemsInCart_ItemDataBound" runat="server"> <HeaderTemplate> <table> <thead> <tr>
<asp:Repeater ID="rptItemsInCart"
OnItemDataBound="rptItemsInCart_ItemDataBound" runat="server">
<HeaderTemplate>
<table>
<thead>
<tr>
<th>Service id</th>
<th>Fare</th>
<th>Type</th>
</tr>
<tr>
<asp:Button ID="Button1" runat="server" Text="Button" />
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("serviceId") %></td>
<td><%# Eval("fare")%></td>
<td><%# Eval("busType")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
服务id
票价
类型
这就是你要找的吗?
SqlConnection conn = new SqlConnection(@"Data Source=SQL2008;Initial Catalog=SMS;User ID=sa;password=sql;");
conn.Open();
SqlCommand cmd = new SqlCommand("select * from P1091", conn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds1 = new DataSet();
adp.Fill(ds1);
foreach (RepeaterItem item in rptItemsInCart.Items)
{
DropDownList drop = (DropDownList)item.FindControl("DropDownList1");
drop.DataSource = ds1;
drop.DataTextField = "P_Dent_N";
drop.DataValueField = "P_Dent_N";
drop.DataBind();
drop.Items.Insert(0, new ListItem("---Select---", "0"));
}