我想在asp.net c#
中将下拉列表添加到转发器中我想在点击选择座位(如redbus.in
)时显示登机点的下拉列表怎么做
<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>
答案 0 :(得分:-1)
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"));
}