Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In a grid view I am retrieving data which consists of 4000 records. But it is taking very long time time. In future my number of records can be much more. How can I reduce processing time to retrieve so many number of records.
Posted

One thing is that you can use paging with your gridview. Few examples:
- GridView Custom Paging[^]
- Paging GridView with ROW_NUMBER()[^]
- GridView Custom Paging with PageSize Change Dropdown[^]

Another thing is that you should also concentrate on proper indexing to make the paging and searching efficient. Also consider adding additional restrictive conditions (that user can modify) to your page.

The more you transfer data in one round trip the more time it's going to take so the basic principle is to fetch only what's needed at that moment.
 
Share this answer
 
Comments
Qureshali 6-Sep-11 1:19am    
On that page I have 2 text boxes for start date and end date respectively.
The data I retrieve is between these two dates. I am developing an On line attendance system. Is there any hard code which I can write for fast processing
Wendelius 6-Sep-11 1:41am    
How many rows are returned if the user defines one week (or even one day period)? If it is (or can be) more than 25-50 I think there's too many rows => use paging.

Well, no there's no simple one-solution-fits-all type of code you can write. I think that in this case the amount of rows is the key thing so concentrate in bringing a reasonable amount of rows at a time.

Also as I said before, make sure that the database indexing supports your paging (= define reasonable indexes for fields that are used in paging and searching criteria)
Abhijit Jana 6-Sep-11 1:32am    
+5. There is no need to showing 4000 records same time on grid. This will create page slow by default. Custom Paging or Some filtering should be the best option.
Wendelius 6-Sep-11 1:43am    
Thanks, yes that's so true. :)
I will never suggest to show 4000 Records on GridView. This will unnecessary slow your page and as a end user, I really don't want to see 4000 records at a time. Why not using Custom Paging ? Why not providing filtering on Grid View ? By filtering I means, show the data which is relevant to user.
 
Share this answer
 
Comments
Wendelius 6-Sep-11 1:44am    
Exactly, my 4000, no wait, 5 :)
Dear Friend,

As per My Suggestion while inserting data in Gridview Use Arrays Concept.Searching the Data will be Very Fast.Execution of Application will Become More Efficient.


Regards,
Anilkumar.D
 
Share this answer
 
v2
Comments
Qureshali 6-Sep-11 1:19am    
Can you help me out how to use array concepts while inserting data in grid view
protected void Page_Load(object sender, EventArgs e)
{
//1 dimensional Array::::
string[] array = { "Anil","Kumar","Anilkumar","Eresh","Archana" };
Grid1D.DataSource = array;
Grid1D.DataBind();
//2 Dimensional array::::
string[,] arra1 ={

{ "John", "21" },

{ "Smith", "33" },

{ "Ryder", "15" },

{ "Jake", "18"},

{ "Tom","34" }

};
ArrayList arraylist = new ArrayList();
for (int i = 0; i < 5; i++)
{
arraylist.Add(new ListItem(arra1 [i, 0], arra1 [i, 1]));

}
Grid2D.DataSource = arraylist;
Grid2D.DataBind();

//Multi Dimensional Array:::::
string[,] Multiarray = {

{ "John", "21", "Berlin", "Germany" },

{ "Smith", "33" ,"London", "UK"},

{ "Ryder", "15" ,"Sydney", "Australia"},

{ "Jake", "18", "Tokyo", "Japan"},

{ "Tom","34" , "Mumbai", "India"}

};

DataTable dt = new DataTable();
dt.Columns.Add("Name", Type.GetType("System.String"));
dt.Columns.Add("Age", Type.GetType("System.String"));
dt.Columns.Add("City", Type.GetType("System.String"));
dt.Columns.Add("Country", Type.GetType("System.String"));
for (int i = 0; i < 5; i++)
{
dt.Rows.Add();
dt.Rows[dt.Rows.Count - 1]["Name"] = Multiarray[i, 0];
dt.Rows[dt.Rows.Count - 1]["Age"] = Multiarray[i, 1];
dt.Rows[dt.Rows.Count - 1]["City"] = Multiarray[i, 2];
dt.Rows[dt.Rows.Count - 1]["Country"] = Multiarray[i, 3];
}
GridMultiD.DataSource = dt;
GridMultiD.DataBind();


String[] data = { "test-1", "test-2", "test-3", "test-4", "test-5" };
GridViewTest.DataSource = from d in data
select new { myColumn = d };
GridViewTest.DataBind();

}

Friend Understand This Code in proper way and Execute in your Application.
 
Share this answer
 
Use one Ajax control then u can get fast working Gridview.
 
Share this answer
 
Comments
Qureshali 6-Sep-11 1:41am    
What is the name of that Ajax control

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