Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139