T
Tumurbaatar S.
All my datagrids need editing, deleting, sorting and paging. Datagrid's view
state is enabled,
but it is disabled it for each DataGridItem after binding. Also, I use
DataAdapter instead of
DataReader because the last one does not work with paging and sorting.
My typical data binding code looks like this:
string sql = "SELECT .... FROM tbl"; // a query does not contain ORDER BY
clause
SqlDataAdapter cmd = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
cmd.Fill(ds);
DataView dv = ds.Tables[0].DefaultView;
dv.Sort = sort; // a string like "some_fld DESC, another_fld ASC"
DataGrid.DataKeyField = "key_fld"; // specify a key field for update/delete
events
DataGrid.DataSource = dv;
DataGrid.DataBind();
And I thought, may be, using a sorting order directly in a SELECT statement
can improve a performance? I.e.:
string sql = "SELECT .... FROM tbl ORDER BY " + sort;
and removing following line:
dv.Sort = sort;
Also, any other ideas to increase performance of data binding without adding
a much of code?
state is enabled,
but it is disabled it for each DataGridItem after binding. Also, I use
DataAdapter instead of
DataReader because the last one does not work with paging and sorting.
My typical data binding code looks like this:
string sql = "SELECT .... FROM tbl"; // a query does not contain ORDER BY
clause
SqlDataAdapter cmd = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
cmd.Fill(ds);
DataView dv = ds.Tables[0].DefaultView;
dv.Sort = sort; // a string like "some_fld DESC, another_fld ASC"
DataGrid.DataKeyField = "key_fld"; // specify a key field for update/delete
events
DataGrid.DataSource = dv;
DataGrid.DataBind();
And I thought, may be, using a sorting order directly in a SELECT statement
can improve a performance? I.e.:
string sql = "SELECT .... FROM tbl ORDER BY " + sort;
and removing following line:
dv.Sort = sort;
Also, any other ideas to increase performance of data binding without adding
a much of code?