0
Reply

sortcode for DataGrid control

rathi rathi

rathi rathi

May 31 2006 7:49 AM
1.8k
protected void Sortdg_SortCommand(object source, DataGridSortCommandEventArgs e) { if (!Page.IsPostBack) { SqlConnection BindConnection = new SqlConnection("Data Source=AB2\\SQLEXPRESS;Initial Catalog=Tiger;Integrated Security=True"); SqlCommand comBindData = new SqlCommand("select * from stock", BindConnection); comBindData.CommandType = CommandType.Text; SqlDataAdapter myAdapter = new SqlDataAdapter(comBindData); DataSet ds = new DataSet(); myAdapter.Fill(ds); DataView dvSort = new DataView(ds.Tables[0]); Sortdg.DataSource = dvSort; Sortdg.DataBind(); dvSort.Sort = e.SortExpression; } } This above code I am using to sort my datagrid but its not working out give me a solution with the same code or a different one. Regards, Rathi