473,396 Members | 1,923 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,396 software developers and data experts.

DataBind and GridView

Hi,

I am going to create two aspx pages.
The first page will display the whole content of a table which is from a DataSet.
Expand|Select|Wrap|Line Numbers
  1.  
  2. DataSet myDataSet = new DataSet(); 
  3.  try
  4.         {
  5.             myConnection.Open();
  6.             // create the data
  7.             GenerateDataSet(myDataSet, myConnection);
  8.         }
  9.         finally
  10.         {
  11.             myConnection.Close();
  12.             // bind each to table to a grid
  13.             GridView1.DataSource = myDataSet.Tables["Weather"];
  14.         }
  15.         // databind the page
  16.         GridView1.DataBind();
The second page will only display few selected columns of the table.
My questions are
1) How can the contents in the second page be binded with the datasource?
Suppose I don't want to create the second table.
2) How can I pass the data source from the first page to the second page?


Thanks.
Feb 8 '08 #1
2 1733
dip_developer
648 Expert 512MB
If possible execute a fresh query on the second page...or pass a primary key information in Querysting by which you can retrieve required records.................
On the otherhand you can keep your dataset to Session or Cache variable............but you have to consider many aspects of storing a dataset to session or cache....

here is some point ::
**********************************

If you decide to save a dataset between round trips, you must decide where to keep it. This issue is the
standard one of state maintenance in Web Forms pages — where do you store information you want to
preserve between round trips?
You have two options:
On the server, save the dataset in Session state, Application state, or using a cache.
On the client — that is, in the page — save the dataset using view state or by putting the data into your own hidden field. ( View state is also implemented using a hidden field. )

Storing the dataset on the server uses server resources. If you store too much data ( a large dataset, or many users storing small datasets ), it can affect server performance and scalability. Using a cache can partly offset this problem, because the cache manager
will discard the dataset if the server needs memory or if cached data expires. But because the dataset is not guaranteed to be in the cache, you must add logic to your page to check that the dataset is available in the cache; if not, you must recreate it and put a copy back in the cache.
Storing data in the page means that you do not need server resources to save the data. However, the data becomes part of the HTML stream of the page. If the dataset is large, it can substantially affect the
time it takes for the page to load into the user's browser and to post the page back to the server.
TIP: Always try to keep the size of a dataset to a minimum by filling it with only the records you need.
No matter where you decide to store the dataset, you must add logic to your page to save it and restore it at the appropriate time. The following example shows a typical way to store and restore a dataset in Session state. The dataset dsCustomers1 is an instance of the dataset class dsCustomers. Note that the dataset is stored in Session state as type Object. When restoring the dataset from Session state, you must cast it from Object back to a dataset class.

Expand|Select|Wrap|Line Numbers
  1. private void Page_Load ( object src, EventArgs e )
  2. if ( Page.IsPostBack )
  3. {
  4. dsCustomers1 = ( dsCustomers ) Session [ "myDsCustomers" ];
  5. }
  6. else
  7. {
  8. if ( Session [ "myDsCustomers" ] == null )
  9. {
  10. oleDbDataAdapter1.Fill ( dsCustomers1 );
  11. Session [ "myDsCustomers" ] = dsCustomers1;
  12. }
  13. }
  14. }
Feb 8 '08 #2
Thanks for your reply. I will study on the skills of dataset in Session state.
It's brand new to me.
Feb 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jslaybaugh | last post by:
I am trying to bind to a GridView or DetailsView after a callback using the ClientCallback Manager in the new .NET 2.0 framework. See below for the HTML followed by the VB code: <html...
0
by: sreejith.ram | last post by:
I did google & search in this group , but couldnt find any thing related to this. This is my first attempt to connect GridView to a Oracle database via SqlDataSource. I am receving error message...
3
by: K B | last post by:
Hi again, I've narrowed down my problem and am hoping to get some help to get the final answer. Gridview with dynamic child controls loads gv1.Databind calls RowDataBound event fine On the...
3
by: Mark Leistner | last post by:
I am having problems getting a gridview to bind to custom objects under any non-full trust level. I created a test project to verify what I am seeing isn't a side effect of other code in my...
0
by: ack95 | last post by:
Simply question How can I DataBind() a DataViewManager to a GridView in ASP.NET? Question in Detail We have a DataSet with relational DataTables (total of 5). We are generating emails with...
1
by: Mark Olbert | last post by:
I have a GridView as a child control in a custom composite control which is stubornly refusing to databind at design time. I'm convinced I must be missing something about how the databinding process...
3
by: gihope | last post by:
Can anyone tell me why I am not allowed to bind a two or multi dimensional array to GridView and possibly suggest how they would deal with similar scenarios? The array is simply a two dimensional...
3
by: Dave | last post by:
I have an GridView on one page that will open a popup for the selected record. I've been told that there is a way that when the popup record is updated the GridView can be refreshed or Databind. ...
1
by: =?Utf-8?B?cmxt?= | last post by:
I have standard gridview in an updatePanel with an AJAX timer that refreshes the data every 5 seconds by calling the grids DataBind method in the tick event. This works great. However, I have a...
2
by: Andy B | last post by:
I don't know if this is even working or not but here is the problem. I have a gridview that I databound to a dictionary<string, stringcollection: Contract StockContract = new Contract();...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.