将数据分成2个gridview表 [英] split data into 2 gridview tables

查看:72
本文介绍了将数据分成2个gridview表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



VB.net/asp.net; vs2010

我在Access数据库中大约有50条记录,
我希望这些记录显示在aspx页面上显示的2个gridviews中

任何帮助将不胜感激.

谢谢
Joe

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

推荐答案

为此,您需要执行以下步骤..

1)首先使用此查询在您的表中计算总记录..
For this you need to follow this steps..

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



此查询导致您的表中的记录总数..
将此结果存储在一个int行中.

2)现在像这样计算一半行int Counter = row/2;

3)在获得总记录数之后,现在触发此选择查询..



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..

SELECT * FROM "YOUR TABLE" WHERE ID <= @COUNTER ORDER BY ID



4)@Counter是您需要传递的参数.

5)现在,使用两步查询的结果填充您的DataTable或DataSet.

6)将数据源关联到gridview 1

7)现在触发第二个查询



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

SELECT * FROM "YOUR TABLE" WHERE ID > @COUNTER ORDER BY ID



8)现在填充您的第二个数据表或数据集,并将其作为数据源分配给您的gridview 2


这样,您可以根据需要将表的数据填充到一个网格中,一半填充到第二网格中.


像这样,您可以使用划分的条件编写自己的查询,并根据该条件将数据拖到网格中.

如果我的ans对您有帮助,请给它评分,如果它是您想要的,请接受它作为ans.



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.


这篇关于将数据分成2个gridview表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆