分页查询字符串中的问题 [英] problem in query string for paging

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

问题描述

大家好
我的页面加载了很多数据,因此我在其中使用了分页.
如果我更改了该分页的索引(例如从第一页到第三页)
我用带有该值的查询字符串重新加载页面.
这里的问题是,在某些情况下,我使用查询字符串,而另一些则不使用.
如果我要查询查询,则出现错误

我试过了,但是有一个错误

Hi all
I have a page that loads a lot of data , so I used paging in it.
if I change the index of that paging (like from the first page to the third page)
I reload the page with query string carry that value.
The problem here, there are some cases I use query string and some other no.
In the case I want query sring, there is an error

I tried that but there is an error

NameValueCollection n = Request.QueryString;
if (n.HasKeys())
{
    // Get first key and value
    string Current = n.Get(0);
    // Test different keys
    if (Current == "page")
    {
        if ((Request.QueryString["page"].ToString().Trim() != string.Empty))
        {
           CurrentPage = Convert.ToInt16(Request.QueryString["page"]);
           fill_Account();
        }



任何帮助,
谢谢

[edit]将内联代码转换为代码块(保留格式),大写,删除了乱码"iii"-OriginalGriff [/edit]



any help,
thanks

[edit]inline code converted to code block (It preserves the formatting), capitalization, removed spurious "iii" - OriginalGriff[/edit]

推荐答案

我相信以下内容代码将为您工作:

I believe the following code will work for you:

if (Request.QueryString["page"] != null && !String.IsNullOrEmpty(Request.QueryString["page"].ToString().Trim())){
    CurrentPage = Convert.ToInt16(Request.QueryString["page"]);
    fill_Account();
}


这将验证查询字符串中是否包含键Page,并且其值不为空或为null.如果满足这些条件,它将继续您需要的功能.


This will verify if you have the key Page in the query string and its value is not empty or null. If these conditions match it will proceed with the functionality you need.


这篇关于分页查询字符串中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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