在具有分页的网格视图中排序 [英] Order by in a grid view with paging

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

问题描述

大家好,

i我正在开发一个电子商务网络应用程序。

我有一个带有网格视图内容产品的网页,paging = true。

当我订购时,例如,按价格订购,它工作正常,但仅在第一页,因为当我在第二页更改时,它按命令丢失了订单,并且没有订购。



我该如何解决这个问题?



我的尝试:



Hi all,
i am developing a e-commerce web application.
I have a web page with a grid view content products , paging=true .
When i order ,for example, order by price, it works fine but only in the first page because when i change in second page, it lost the order by command and doesn't order by.

How can i fix this ?

What I have tried:

Hi all,
i am developing a e-commerce web application.
I have a web page with a grid view content products , paging=true .
When i order ,for example, order by price, it works fine but only in the first page because when i change in second page, it lost the order by command and doesn't order by.

How can i fix this ?

推荐答案

EmanuelPirovano [ ^ ]在评论中写道:
EmanuelPirovano[^] wrote in the comment to the question:

SqlDataSource1.SelectCommand = "SELECT ID, NomeProdotto, DescrizioneProdotto, PrezzoProdotto, Data , Quantità FROM aProdotti WHERE NomeProdotto like '%" + TextBox1.Text + "%' OR DescrizioneProdotto like '%" + TextBox1.Text + "%' ORDER BY PrezzoProdotto ASC"





这是按函数的sql搜索顺序,它仅适用于网格视图的第一页,当我转换时ch进入2页,它丢失了sql命令并设置为随机项。



This is the sql search-order by function and it works only in the first page of grid view, when i switch into 2 page, it lost the sql command and set as random the items.





正如我所提到的,你的代码是 SQLInjection [ ^ ]易受攻击!您必须使用参数化查询!

请参阅:

如何:防止ASP.NET中的SQL注入 [ ^ ]

在SQL Server中编写安全动态SQL [ ^ ]

演练:仅使用存储过程(C#) [ ^ ]



我不明白你的意思是说:订购通过分页的网格视图。因此,我可以提供MSDN文档的链接,例如:

教程25:通过大量数据进行有效分页 [ ^ ]

在DetailsView Web服务器控件中进行分页 [ ^ ]

在GridView Web服务器控件中进行分页 [ ^ ]



As i mentioned, your code is SQLInjection[^] vulnerable! You have to use parameterized queries instead!
See:
How To: Protect From SQL Injection in ASP.NET[^]
Writing Secure Dynamic SQL in SQL Server[^]
Walkthrough: Using Only Stored Procedures (C#)[^]

I have no idea what you mean by saying: "order by in a grid view with paging". So, i can provide links to MSDN documentation, eg.:
Tutorial 25: Efficiently Paging Through Large Amounts of Data[^]
Paging in a DetailsView Web Server Control[^]
Paging in a GridView Web Server Control[^]


这篇关于在具有分页的网格视图中排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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