Showing posts with label SPList Caml Query. Show all posts
Showing posts with label SPList Caml Query. Show all posts

Friday, June 17, 2011

retrieve unique rows from sharepoint List

To retrieve the unique rows from the sharepoint list use the "DefaultView" of the DataTable.
public DataTable GetLeaveAppliers()
        {
 using (SPSite site = new SPSite(SPContext.Current.Site.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Leave Plan"];
                    SPQuery q = new SPQuery();
                    string query = "";
                    q.Query=query;
                    DataTable dt = list.GetItems(q).GetDataTable();
                    DataTable row= dt.DefaultView.ToTable(true, "Author");


                    return row;


                }

            }
}