Thursday, 26 June 2014

SharePoint SPQuery OrderBy

SPList list = SPContext.Current.Web.Lists["Listb"];
SPQuery query = new SPQuery();
string camlquery = "<OrderBy><FieldRef Name='Title' /></OrderBy>";
query.Query = camlquery;
DataTable dt = new DataTable();
dt = list.GetItems(query).GetDataTable();
GridView1.DataSource = dt;
GridView1.DataBind();