473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Large DataSets and GridView Problems displaying data more than once!

I'm having problems getting the GridView to reliably display a large
amount of data (50,000+ rows).

I am working my way through the excellent book “Real World ASP.NET
Best Practices” by Farhan Muhammad. In some cases I’m trying to
extend the examples.
Currently, I have the following code to read data from a SQL Server
2005 database and display in a GridView:
DataSet MyDataSet = new DataSet();
SqlDataAdapter MyAdapter = new SqlDataAdapter();
SqlCommand MyCommand = new SqlCommand();
MyCommand.Connection = new SqlConnection(MyConnection);
MyCommand.CommandText = " select * from Table_1";

MyAdapter.SelectCommand = MyCommand;
MyCommand.Connection.Open();
MyAdapter.Fill(MyDataSet);

GridView1.DataSourceID = "";
GridView1.DataSource = MyDataSet.Tables[0].DefaultView;
GridView1.DataBind();
MyCommand.Connection.Close();
MyCommand.Dispose();

I created Table_1. It’s just a list of firstnames, lastnames. The code
works the first time and the GridView displays the 50,000 data. But
when I hit the button again, I get “Internet Explorer cannot display
the webpage”. I’ve verified that the first line of code is not even
hit AND SQL Profiler shows no database activity. What’s going on?
I’d be the first to admit, that one would not normally have a table
with 50,000+ records, and want to display all of the records (no
filter!) in a GridView, but I’d still like to know what is going on.

Incidentally, the original exercise (from Ch.2 of the book) searched
for a specific record with:
MyCommand.CommandText = " select * from Table_1 where firstname = '" +
txtFirstName.Text + "' ";

The point of the exercise was to show that it was faster to go
directly to the database rather than hit cache. I found this to be
true if one used the binding methods suggested by the authors:

DataSet MyDataSet = Cache["Result"] as DataSet;
DataView MyDataView = new DataView(MyDataSet.Tables[0]);
MyDataView.RowFilter = "firstname = '" + txtFirstName.Text + "' ";
GridView1.DataSourceID = "";
GridView1.DataSource = MyDataView;
GridView1.DataBind();

However, if one uses the following:

DataSet MyDataSet = Cache["Result"] as DataSet;
DataSet newDataSet = new DataSet();
newDataSet.Merge(MyDataSet.Tables[0].Select("firstname = '" +
txtFirstName.Text + "' "));
GridView1.DataSourceID = "";
GridView1.DataSource = newDataSet.Tables[0].DefaultView;
GridView1.DataBind();

Then, going to cache is faster than going to the database.
Admittedly, this idea of Merging datasets may not have existed when
the book was written (2003), and/or I’ve missed something important.
Opinions?

Thanks,
Dave

Jul 12 '08 #1
1 7219
Hi,,,

First of all 50,000 row in a single page.... not seems to be very
helpfull...
To create 50000 row at once will add huge amount of html markup in
page...

I would better do a paged view of the data ... and make sure that i
only
fetch only the data of the current page...

http://www.codeproject.com/KB/aspnet...gGridView.aspx

Best of luck

-----------
Munna

www.munna.shatkotha.com/blog
www.munna.shatkotha.com
www.shatkotha.com
Jul 12 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Salad | last post by:
Every now and then I see ads that state something like "Experience with Large Databases ...multi-gig...blah-de-blah" And I have to laugh. What's the difference between a large or small database? ...
11
by: Brian Henry | last post by:
Well here is the problem, I have a data set with about 9,000 to 20,000 people in it in the data table "people"... I am then reading it into a list view one at a time row by row... adding each...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
4
by: Jim Katz | last post by:
I have an application that updates a strongly typed data set at run time. I'd like to dynamically create a table that connects to a run time data table. For displaying the data, this works well. ...
9
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
10
by: Peter Duniho | last post by:
This is kind of a question about C# and kind of one about the framework. Hopefully, there's an answer in there somewhere. :) I'm curious about the status of 32-bit vs 64-bit in C# and the...
3
by: Don Miller | last post by:
In my migration from ASP to ASP.NET 2.0, I have a fair number of complicated HTML tables that defy anything .NET can do. Using classic ASP I created these tables (by string concatenation) by moving...
4
by: Luke Davis | last post by:
I've been programming in C# for about 3 months now and I've completed a previous project that worked a lot with data, so I know the basics. This is what I need to do, try and see what you would...
12
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.