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

VB.net/asp.net; vs2010

i have around 50 records in an access database,
i would want these records to be shown in 2 gridviews displayed on an aspx page

any help would be appreciated.

thanks
Joe
Posted
Comments
[no name] 4-Oct-11 12:10pm    
And what are you having difficulty with?
Pradeep Shukla 4-Oct-11 16:19pm    
Based on what criteria you would split the data in 2 grids or you just want to repeat data in both of them..be specific...
joe_j 5-Oct-11 3:58am    
its to divide the number of rows equally between 2 gridviews

1 solution

For this you need to follow this steps..

1) First of all count a total record in your table using this query..
SQL
SELECT COUNT(*) FROM "YOUR TABLE NAME"


this query resulted in total number of record in your table..
store this result in one int Row.

2) Now calculate half row like this int Counter = row/2;

3) after getting total no of record now fire this select query..
SQL
SELECT * FROM "YOUR TABLE" WHERE ID <= @COUNTER ORDER BY ID


4) Here @Counter is a parameter you need to pass.

5) Now fill your DataTable or DataSet with the result of 2 steps query.

6) assining a datasource to your gridview 1

7) Now Fire Second Query
SQL
SELECT * FROM "YOUR TABLE" WHERE ID > @COUNTER ORDER BY ID


8) Now fill your second datatable or dataset and assign it to as datasource to your gridview 2


by this you can fill your table's data halfly to one grid and halfly to secod grid as per your requirement.


like this you can write your own query with your divided criteria on which base you want to divide data in tow grid.

if my ans help full to you please rate it and also if it is what you want then accept it as ans.
 
Share this answer
 
v2
Comments
joe_j 5-Oct-11 4:19am    
hi Tejas, well im not a big time programmer so not quite clear on your answer above
joe_j 5-Oct-11 4:36am    
and as of now i have linked the gridview directly to an access DB using an accessdatasource.
and do i need to add the "counter" field in the access DB as sequence numbers for every row?
and is there a way to first get the data in ascending order and then display it in each gridview? coz if i add the counter in the DB then that might not be possible as it might just take up the numbers less than or greater that the half of rows
Tejas Vaishnav 5-Oct-11 7:35am    
@COUNTER is a VARIABLE of SQL, No need to add it to your database.
joe_j 6-Oct-11 14:37pm    
thanks Tejas, though i didnt not use the above exactly coz i was a bit confused but you sure did put me on the right track. thanks a lot man.
i would try to use your code into mine so that i can make it better
Tejas Vaishnav 7-Oct-11 0:35am    
Thanks..!!!
My Code is only for guide you not for your actual code, i just hint you how to do, that's why i tell that you can write your own query from the idea of my query...

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