asp:LinqDataSource question - dynamically passing in WHERE conditions from a collection

I am looking to pass in multiple 'RoleID' values from my code behind. Here is the HTML:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<asp:HiddenField ID="hdnRoleIDfield" runat="server" />
            <input type="hidden" id="hdnSelectedOption" runat="server" class="hdnSelectedOption" value="link_filter"/>

 
 <asp:LinqDataSource ID="linqTabStrip" runat="server" TableName="SiteNavigations" ContextTypeName="AuditTrack.Data.AuditTrackDataContext"
        Where="RoleID == @RoleID" >
       
<WhereParameters>
              <asp:ControlParameter Name="RoleID" ControlID="hdnRoleIDfield" PropertyName="Value"  DefaultValue="0" DbType="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The HTML code I have copied above is how I pass one int value to the WhereParameter. Any thoughts on how I pass to the LinqDataSource the collection of ID's that I receive from the GetRoles() method?

public partial class User
    { public List<Role> GetRoles()
        {
            List<Role> roles = new List<Role>();
            foreach (UserRole userRole in this.UserRoles)
                roles.Add(userRole.Role);

            return roles;
        }
}

 AuditTrack.Data.User user = AuditTrack.Data.User.Get(AuditTrack.Data.User.CurrentUserID);


               hdnRoleIDfield = user.GetRoles();
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



brad_lubAsked:
Who is Participating?
 
brad_lubConnect With a Mentor Author Commented:
I got it to work by providing the control that was using the linqDataSource a filtered DataSource (see below)...

AuditTrack.Data.User user = AuditTrack.Data.User.Get(AuditTrack.Data.User.CurrentUserID);

             
               var siteNav = (from sn in db.SiteNavigations
                              join r in db.Roles
                                 on sn.RoleID equals r.ID
                              join ur in db.UserRoles
                              on r.ID equals ur.RoleID
                              join u in db.Users
                               on ur.UserID equals u.ID
                              where u.ID == user.ID
                              select sn).ToList();

               Radtabstrip1.DataSource = siteNav;
                Radtabstrip1.DataBind();

Thanks for your comments...


0
 
brad_lubAuthor Commented:
Great article but it does not address the issue of passing to theLinqDataSource's WHERE Parameter a collection/list of ID's that I receive from a method.
0
All Courses

From novice to tech pro — start learning today.