Saturday, April 3, 2010

Binding dropdown to linq business object

first we need to create commonmanager class that holds the business object

public class CommonManager
{

    public static List ListGroups()
    {
        DataClassesDataContext db = new DataClassesDataContext();
        return db.Groups.ToList();
    }

}

 // Binding directly to a LINQ business object.
            this.rcbCommunities.DataSource = CommonManager.ListGroups();
            this.rcbCommunities.DataTextField = "GroupName";
            this.rcbCommunities.DataValueField = "GroupId";
            this.rcbCommunities.DataBind();

No comments:

Post a Comment