在asp.net中处理Gridview分页 [英] Handle Gridview Paging in asp.net

查看:61
本文介绍了在asp.net中处理Gridview分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Gridview 中获取了我的数据库值,我已经实现了分页,然后我将数据导入 excelsheet ,我已经做了所有这些事情,现在我想添加更多功能如下。



我添加了两个单选按钮前100行全部显示。我想在用户选择合适的单选按钮时显示前100行,并在选择其他单选按钮时显示大量数据。



任何人都可以为我提供一些想法??

I got my Database values in Gridview and I have implemented the paging, Then I am importing data to excelsheet, I have done all these things and now I want to add more functionality as follows.

I have added two radio buttons that are "Top 100 rows" and "Show All". I want to show top 100 rows when user select the appropriate radio button and show whole bunch of data on selection of other radio button.

Can anyone one provide me with some idea??

推荐答案

下面是简单的代码,让您了解如何获取前100条记录。这实际上是一个想法,可以清楚地说明如何获取前100行。



Below is the simple code to make you understand how to fetch Top 100 records. This is actually an idea to make it clear how you can do to fetch Top 100 rows.

private DataTable GetDatasource()
{
    DataTable dtable = new DataTable();
    string _Query = string.Empty;
    _Query = "SELECT TOP 100 * FROM Customers";
    //Do the other stuffs here to fetch Top 100 records from Database.
    return dtable;
}

// On Radion Button Click event 
protected void btnRadioButton1_Click(object sender, EventArgs e)
{
   //Here the dtable will have Top 100 rows from Database. If you want to show this in the gridview assign the dtable to the gridview datasource.
   DataTable dtable = GetDatasource();
   //Export the dtable record to excel
   GridViewExportUtil.Export("Customers.xls", dtable);
}



希望它有所帮助。


Hope it helps.


为raddio button1选择事件写一个sql查询

ie string conString =从表名中选择前100名[columnsname]或[*];

..

for radiobuttion2:

string conString =从表名中选择[columnsname]或[*]
write a sql query for raddio button1 select event
i.e string conString="select top 100 [columnsname]or [*] from tablename";
..
for radiobuttion2:
string conString="select [columnsname]or [*] from tablename"


这篇关于在asp.net中处理Gridview分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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