Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Tumurbaatar S. #1
Optimizing binding
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?
Tumurbaatar S. Guest
-
Help Optimizing Query
Just looking to see if anyone has any pointers on how i can optimize this query... it is taking about a minute to show the data, and even though its... -
Complex data binding question, binding child objects of a custom collection.
I have a custom collection of objects, each of which includes a child object called MyUserOpener. In declarative binding, I can bind this property... -
Optimizing Coldfusion
ronnie, first off since you failed to read the rules, double posting is against the rules. I don't know why you double posted, I probably pissed you... -
Optimizing PDF
Hey, I have a pdf that i am trying to optimize because it is 14 megs in size. WHen i use the pdf optimizer, i get an message that says "THe... -
Optimizing Query
Can anybody tell me how to improve the performance of this query? SELECT NID, LEVEL, VALUE FROM DATA WHERE DID=2 AND STATUS=0 The value of... -
Elton Wang #2
Re: Optimizing binding
If you compare Sorting in sql query and in dataview, the first one should
have better performance.
However when user clicks any column header in the datagrid, you need to
conduct sorting again. If you save the query result (dataview) in Session
when in the beginning, you can get the dataview from Session and sort it. It
apparently has better performance than re-query DB.
HTH
"Tumurbaatar S." <spam_tumur@magicnet.mn> wrote in message
news:%23Tk5ioh1FHA.1108@TK2MSFTNGP14.phx.gbl...> 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?
>
>
Elton Wang Guest



Reply With Quote

