ods_选定行数
我有以下代码,它提供了绑定到对象数据源的 gridview 中的行数。
protected void odsProduct_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
lblHowManyRows.Text = ((List<tblProduct>)e.ReturnValue).Count.ToString();
迷人的。
但是,在对象数据源生成 gridview 输出之前,我将如何基本上进行相同的计数?
我想做的是让用户有机会检查在实际创建 gridview (绑定到对象数据源)之前将返回多少行。ods
中是否有某些内容,或者我应该编写另一个 linq 语句并将其绑定到那个?
为我的无知道歉
I have the following bit of code that gives me the number of rows in a gridview bound to an object data source.
protected void odsProduct_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
lblHowManyRows.Text = ((List<tblProduct>)e.ReturnValue).Count.ToString();
Lovely.
However, how would I go about essentially doing the same count but before the object data source produces the gridview output?
What I am trying to do is give the user the chance to check how many rows would be returned before they actually create the gridview (bound to the object data source)
Is there something that lies within the ods or should I just write another linq statement and bind it to that?
Apologies for my ignorance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么,您可以有一个如下所示的 OnSelecting 事件:
第一次将标签设置为计数,并在下次检索数据。
下次 lblHowManyRows 不会为空,因此它将进入您的 odsProduct_Selected 方法:
清空标签,以便用户可以继续选择。这样,他们第一次单击时仅获得计数,下次单击时获得完整的网格范围。
如果是我,我很可能会通过 AJAX/webservice 检索完整的计数,而不进行回发或根本使用 gridview,但我不知道问题的完整上下文。
Well, you could have an OnSelecting event such as this:
where it sets the label to the count the first time, and retrieves the data the next time.
The next time the lblHowManyRows won't be empty, so it'll make it to your odsProduct_Selected method:
Blank out the label so that the user can continue to select. This way the first time they click they get only the count and the next time they click they get the full grid bound.
If it were me, I'd most likely retrieve the complete count via AJAX/webservice without doing a postback or using the gridview at all, but I don't know the full context of the question.