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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
brad_lubAuthor 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.