protected void fillgrid() { DataTable dt = new DataTable(); dt = obj.selectGriddata_role(compid); DataView myDataView = new DataView(); myDataView = dt.DefaultView; if (hdnsortExp.Value != string.Empty) { myDataView.Sort = string.Format("{0} {1}", hdnsortExp.Value, hdnsortDir.Value); } GridView1.DataSource = myDataView; GridView1.DataBind(); }