与asp.net gridview [英] gridview with asp.net

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

问题描述

我对网格视图有疑问..我有一个缺少1条记录的数据库..假设如果我想一次检索1条缺少数据库的记录,那么数据库性能将会下降..我想检索这些记录基于页面大小..假设我按第一页按钮仅从数据库调用前100条记录,而我按第二页按钮仅调用101-200条记录,我的页面大小为100.谢谢

I have a doubt on grid-view.. i have a database with 1 lack records.. suppose if i want to retrieve 1 lack database records at a time the database performance will be decreasing.. i want to retrieve the records based on the page size.. suppose my page size is 100 if i press first page button call first 100 records only from database..and i press 2nd button call 101-200 records only..can any one help for this problem.. thank you

推荐答案

除了在gridview中分页外,什么都没有

添加Gridview


its nothing but paging in gridview

Add Gridview


<asp:gridview id="DgTest" runat="server" autogeneratecolumns="False" xmlns:asp="#unknown">
            Width="100%" AllowSorting="True" OnRowCommand="DgTest_RowCommand" 
            OnRowDataBound="DgTest_RowDataBound" AllowPaging="True" 
            onpageindexchanging="DgTest_PageIndexChanging" CaptionAlign="Right"> </asp:gridview>



将PageIndexChanging事件创建为



Create PageIndexChanging event as

protected void DgTest_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            DgTest.PageIndex = e.NewPageIndex;
            Populate();
        } 





private void Populate()
        {
            //Code To get datasource to Databind
        }


不要忘记设置属性Pagesize = 100


Dont forget to set property Pagesize=100


使用GridView的分页和排序概念


阅读以下概念链接:
http://msdn.microsoft.com/en-us/library/aa479347.aspx [ ^ ]

http://www.c-sharpcorner.com/uploadfile/rohatash /gridview-paging-sample-in-asp-net/ [
Use Paging and Sorting concept of GridView


Read the following links for concepts:
http://msdn.microsoft.com/en-us/library/aa479347.aspx[^]

http://www.c-sharpcorner.com/uploadfile/rohatash/gridview-paging-sample-in-asp-net/[^]

set pagesize property to 100


有很多有效的方法可以从数据库中查询n条记录.

There are so-many efficient ways to query n records from the data base.

SELECT TOP numberofrecordsyouwanttotake
    [yourColumns...]
FROM tableName
WHERE yourIDColumn NOT IN (
    SELECT TOP numberofrecordsyouwanttoskip
        yourIDColumn
    FROM tableName
    ORDER BY yourOrderColumn
)
ORDER BY yourOrderColumn




谢谢!!!




Thanks!!!


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

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