Create a Repeater control in ASP.Net

帅比萌擦擦* 提交于 2019-12-02 03:01:55

You can achieve the desired result using Repeater control of ASP.Net. You can create any type of template as you wish, see the code below:

ASPX:

<asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
        <asp:DropDownList ID="DropDownList1" runat="server" />
        <asp:DropDownList ID="DropDownList2" runat="server" />
        <br />
    </ItemTemplate>
</asp:Repeater>

CodeBehind:

protected void Button1_Click(object sender, EventArgs e)
{
    // data fetching logic

    Repeater1.DataSource = data;
    Repeater1.DataBind();
}

Hard to answer without a better explanation and code samples but from experience doing anything with dropdowns over postbacks is better controlled with hidden fields. Set the value of the hidden field with javascript. Please provide more detail.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!