c# - ASP.NET Webforms Binding a List of Links To a User Based on there Role, for a View .ASPX -


i have been trying figure out hour now. familiar how in mvc, company uses webforms , trying think in terms of webforms, problem beating me.

well using asp identity, roles , entity framework, need figure out how list of hyperlinks user assigned based on role display when page loads. have hyperlinks stored in database, navigates different part of site.

the code using in code behind , .aspx view listed below.

namespace website {     public partial class membercenter : system.web.ui.page     {         protected website.models.websitedbcontext _db = new website.models.websitedbcontext();          protected void page_load(object sender, eventargs e)         {            }          public iqueryable<website.models.rolelink> getdata()         {              if (httpcontext.current.user.isinrole("admin"))             {                 rolelink rolelinks = _db.rolelinks.where(rl => rl.roleid == 1).firstordefault();             }              return _db.rolelinks;         }     } } 

here part .aspx page. know pretty self explanatory mvc webforms how pass list of links page , display the, if had more 1 list.

<div>     <asp:listview id="linklist" runat="server"         datakeynames=""         itemtype="website.models.rolelink"         selectmethod="getdata">         <emptydatatemplate>             no links associated user         </emptydatatemplate>         <layouttemplate>             <table class="table">                 <thead>                     <tr>                         <th>                             <asp:hyperlink runat="server" href="administration/toolupcms/users/" id="distriblink">tool cms</asp:hyperlink>                         </th>                         <th>&nbsp;</th>                     </tr>                 </thead>                 <tbody>                     <tr runat="server" id="itemplaceholder" />                 </tbody>             </table>          </layouttemplate>         <itemtemplate>             <tr>              </tr>         </itemtemplate>     </asp:listview> </div> 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -