datalist 中的数据分页 使用服务器端编码
我必须对现有应用程序中的数据列表实现数据分页。
我拥有
存储过程 - 具有 if else 条件
If(Seacrh Criteria)
Select based on Search Criteria
Else
Select every product
现在,我想在 aspx 页面上的数据列表中实现数据分页。问题是我需要将 ObjectDataSource 指定给绑定到网格视图的存储过程。
我不想从查询字符串中获取任何参数。由于我有多个 searchrh 参数,另一个原因是我不想回发。
可能我的解释很混乱,因为我想解释每件事。
我会尝试总结一下:
- 我有一个数据列表控件。
- 我想通过使用现有的存储过程进行数据分页。
- 我已经为存储过程创建了一个数据集[通过添加新项目]。 [Product.xsd]
- 我不想从查询字符串中获取任何参数,我需要几乎 15 个必须从服务器端获取的参数。
- 我的存储过程已准备就绪。接下来是这个教程
- 我应该在 ObjectDataSource 的 TypeName 属性中写什么?
Edit1
我见过一个更好的 Linq to Sql 示例,但我的问题是我的存储过程太大,无法转换为 linq 查询。有什么帮助吗?
I have to implement the data paging to the datalist I have in my existing application.
What I have
Stored procedure - which has if else condition
If(Seacrh Criteria)
Select based on Search Criteria
Else
Select every product
Now, I want to implement data paging in the datalist I have on aspx page. The problem is that I need to specify the ObjectDataSource to the stored procedure which is bound to the grid view.
I don't want to take any parameter from the querystring. As I have multiple seacrh parameter, the other reason is that I don't want postback.
Might be my explanation is confusing because I want to explain each and everything.
I will try to summarize it:
- I have a datalist control.
- I want data paging by using the existing stored procedure.
- I have already created a dataset [by Add new Item] for the stored procedure. [Product.xsd]
- I don't want to take any parameter from Querystring, I need almost 15 parameter which I have to take from server side.
- My stored procedure is ready..Followed by this tutorial
- What should I write in the TypeName attribute of the ObjectDataSource?
Edit1
I have a seen a better example with Linq to Sql but my issue is that my stored procedure is too big that it can not be transformed into linq query. Any help ?
您应该能够使用 Session 变量与您的数据源而不是查询字符串。您可能需要编写一些代码来获取搜索条件并将其放入会话变量中。
确实没有办法避免回发。您可以使用 ajax 来减少页面刷新。
You should be able to use Session variables with your datasource instead of QueryString. You may need to write some code to take your search criteria and put them into session variables.
There's really no way to avoid postback. You can mitigate the page refresh by using ajax.