Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I have a small doubt.

I am using paging in my GridView.

OnPageIndexChaged, I bind the GridView again.

but my lead told that is long process, he told another process...
I have doubt about that code.

my code:

C#
protected void ChangeIndex1(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        DataSet ds = DEBLOBJ.USERREQSEARCHDATE(LPOBJ);
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }

    public void LoadGrid()
    {      
       DataSet ds = DEBLOBJ.USERREQSEARCHDATE(LPOBJ);
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }


my lead code:

C#
protected void ChangeIndex(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;      
        GridView1.DataSource = Session["myvalue"];
        GridView1.DataBind();
    }

    public void LoadGrid()
    {
        DataSet ds = DEBLOBJ.GetYPUserReqDetails();
        Session["myvalue"] = ds;
        //HttpCookie mycookie = new HttpCookie("Venkat");
       // mycookie.Value =Convert.ToString(ds);
        UserReqDetailsGrid.DataSource = Session["myvalue"];
        UserReqDetailsGrid.DataBind();
    }


Which one is better? Please give me the best solution for decreasing the server load.
Posted
Updated 30-Jan-11 19:22pm
v2
Comments
Ankur\m/ 31-Jan-11 1:24am    
Is it that you are getting the values from database again and again and your lead saves it in a Session object?
Sandeep Mewara 31-Jan-11 1:28am    
Yep! it looks like that only.
Ankur\m/ 31-Jan-11 1:34am    
OP wrote:
Comment1: i get values from dataset,
my lead get from sessions

Comment2: so, ankur,finally which one is best?
Ankur\m/ 31-Jan-11 1:35am    
Use comments to reply to a user. Hover over a user's comment and you see a reply option.
I do not get notified if you add an answer.
[no name] 31-Jan-11 2:02am    
ok ankur,Use comments to reply to a user. Hover over a user's comment and you see a reply option. I do not get notified if you add an answer.

Among you two, leaving aside the validation (null checks not done!) and assuming not huge amount of data is stored in Session, your lead's code! :)

Simple and foremost reason: You lead's code hit DB once for a set of data and use it again and again while paginating.

Your's in any case is not good. It hits DB every time. Even if it's for small data.

Now, other option to use could be Caching.
 
Share this answer
 
Comments
[no name] 31-Jan-11 1:34am    
hi sandeep thanks for ur answer,

and give me one suggestion for implementing this concept using catching
What I understand is - you are fetching the data again and again from the database and your lead is storing the data in a Session object.

Where are you storing the session? For InProc mode, I would go with your lead's implementation if the rows returned from the database is less. As the number of rows increases you will need to use a combination of both the techniques.
 
Share this answer
 
v2
Comments
[no name] 31-Jan-11 1:35am    
thanks for ur answer
and this concept how to implement using catching
Ankur\m/ 31-Jan-11 2:14am    
Caching should be used if the data is not dynamic. Cached objects will be much faster. You may find a lot of examples on the web. Search for it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900