如何使用asp.net中的下拉菜单动态地从MsSql数据库中获取表

时间:2022-01-10 10:17:59
<asp:DropDownList ID="DropDownList1" runat="server" CssClass="account-content">
            <option value="" onclick="tbl_city"> All</option>
            <option value="">City</option>
            <option value="">State</option>
            <option value="">Country</option>
            <option value="">Project</option>
            <option value="">Project Detail</option>
            <option value="">Project Category</option>
            <option value="">User</option>
            <option value="">User Detail</option>
            </asp:DropDownList>

1 个解决方案

#1


0  

Use Entity Framework. Bind data to the gridview and use SelectedIndexChanged property of DropDownList to Redirect to that page . you can use something like this:

使用实体框架。将数据绑定到gridview,并使用DropDownList的SelectedIndexChanged属性重定向到该页。你可以这样使用:

        private DataEntities dataContext;
          dataContext = new DataEntities1();
         gv.DataSource = dataContext.objectName.ToList<TEntity>();
         gv.DataBind();

#1


0  

Use Entity Framework. Bind data to the gridview and use SelectedIndexChanged property of DropDownList to Redirect to that page . you can use something like this:

使用实体框架。将数据绑定到gridview,并使用DropDownList的SelectedIndexChanged属性重定向到该页。你可以这样使用:

        private DataEntities dataContext;
          dataContext = new DataEntities1();
         gv.DataSource = dataContext.objectName.ToList<TEntity>();
         gv.DataBind();