【问题标题】:how to add dropdownlist dynamically to a particular row dynamically in a repeater如何在转发器中动态地将下拉列表动态添加到特定行
【发布时间】:2015-06-11 16:55:28
【问题描述】:

我想在 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>

【问题讨论】:

标签: c# asp.net asprepeater


【解决方案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"));


        }

【讨论】:

    猜你喜欢
    • 2021-08-04
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2018-07-02
    • 1970-01-01
    • 2011-09-27
    • 1970-01-01
    • 2017-06-30
    相关资源
    最近更新 更多