gridview:“查看y的记录x” [英] gridview: "Viewing record x of y"

查看:71
本文介绍了gridview:“查看y的记录x”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启用分页的girdview。如何在页脚中添加消息

来说查看记录1-15 of 45等等


谢谢

I have a girdview with paging enabled. How can I add a message in the footer
to say "Viewing records 1-15 of 45" etc

Thanks

推荐答案

我想要一个订阅数据源的Selected事件的方法

对象保存在私有变量中检索的总记录,例如


void DataSource1_Selected(对象发送者,ObjectDataSourceStatusEventArgs

e)

{

iTotalRecords =((DataView)e.ReturnValue).Count;

}


然后我会订阅rowCreated事件以构成来自

pageIndex,pageSize和总记录数的消息,例如


void GridView1_RowCreated(object sender,GridViewRowEventArgs e)

{

if(e.Row.RowType == DataControlRowType.Pager)

{

Label lbl = new Label();

//编译标签文本

lbl.Text ="查看记录" +(GridView1.PageIndex *

GridView1.PageSize)+1 +" - +((GridView1.PageIndex + 1)*

GridView1.PageSize)+" 的+ iTotalRecords;

//注意寻呼机模板渲染一个单元格

//有一个HTMLTable

e.Row.Cells [0] .Controls.Add(lbl);

}

}


我没有运行此代码,你可能要调试其中的任何拼写错误,但是它会给你这个想法。

-

HTH,

Phillip Williams
http://www.societopia.net
http://www.webswapp.com

" NH"写道:
I would have a method subscribing to the Selected event of the datasource
object to save total record retrieved in a private variable, e.g.

void DataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs
e)
{
iTotalRecords = ((DataView)e.ReturnValue).Count;
}

Then I would subscribe to the rowCreated event to compose a message from the
pageIndex, pageSize and the total records count, e.g.

void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType==DataControlRowType.Pager)
{
Label lbl= new Label();
//compse the label text
lbl.Text="Viewing records " + (GridView1.PageIndex *
GridView1.PageSize) +1 + " - " + ((GridView1.PageIndex+1) *
GridView1.PageSize) +" of " + iTotalRecords ;
//notice that the pager template renders one cell in which
//there is an HTMLTable
e.Row.Cells[0].Controls.Add(lbl);
}
}

I haven''t run this code, you might have to debug any typos in it, but it
should give you the idea.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"NH" wrote:
我有一个启用分页的girdview。如何在页脚中添加消息
说查看记录1-15 of 45。等等

谢谢
I have a girdview with paging enabled. How can I add a message in the footer
to say "Viewing records 1-15 of 45" etc

Thanks



谢谢Philip,


我会试一试。

N


" Phillip Williams"写道:
Thanks Philip,

I will try this out.
N

"Phillip Williams" wrote:
我将有一个方法订阅数据源
对象的Selected事件,以保存在私有变量中检索的总记录,例如
void DataSource1_Selected(object sender,ObjectDataSourceStatusEventArgs
e)
{
iTotalRecords =((DataView)e.ReturnValue).Count;
}

然后我会订阅rowCreated事件来编写来自
pageIndex,pageSize和总记录数的消息,例如

void GridView1_RowCreated(object sender,GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.Pager)
{
标签lbl = new Label();
//编译标签文本
lbl.Text =查看记录 +(GridView1.PageIndex *
GridView1.PageSize)+1 +" - +((GridView1.PageIndex + 1)*
GridView1.PageSize)+" 的+ iTotalRecords;
//注意,寻呼机模板渲染了一个单元格,其中有一个HTMLTable
e.Row.Cells [0] .Controls.Add(lbl);
}
}
我没有运行这段代码,你可能需要调试其中的任何拼写错误,但它应该给你这个想法。 />
-
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp .com

" NH"写道:
I would have a method subscribing to the Selected event of the datasource
object to save total record retrieved in a private variable, e.g.

void DataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs
e)
{
iTotalRecords = ((DataView)e.ReturnValue).Count;
}

Then I would subscribe to the rowCreated event to compose a message from the
pageIndex, pageSize and the total records count, e.g.

void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType==DataControlRowType.Pager)
{
Label lbl= new Label();
//compse the label text
lbl.Text="Viewing records " + (GridView1.PageIndex *
GridView1.PageSize) +1 + " - " + ((GridView1.PageIndex+1) *
GridView1.PageSize) +" of " + iTotalRecords ;
//notice that the pager template renders one cell in which
//there is an HTMLTable
e.Row.Cells[0].Controls.Add(lbl);
}
}

I haven''t run this code, you might have to debug any typos in it, but it
should give you the idea.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"NH" wrote:
我有一个启用分页的girdview。如何在页脚中添加消息
说查看记录1-15 of 45。等等

谢谢
I have a girdview with paging enabled. How can I add a message in the footer
to say "Viewing records 1-15 of 45" etc

Thanks



我得到了很好的工作,谢谢。我决定显示一条消息查看页面

1 of 2


有没有办法控制标签控件放在寻呼机中的位置

模板?它默认将自己定位在我已经添加到寻呼机设置以便在页面之间导航的其他图像上。如果我想要

将标签控件添加到寻呼机模板的最右侧,那么

有办法吗?

NH写道:
I got it working nicely, thanks. I decided to show a message of "Viewing page
1 of 2" etc.

Is there a way of controlling where the label control is placed in the pager
template? It defaults to positioning itself under some other images I have
already added to the pager setting for navigating between pages. If I wanted
to add the label control to the far right hand side of the pager template, is
there a way to do that?

"NH" wrote:
感谢Philip,

我会试试这个。
N

Phillip Williams写道:
Thanks Philip,

I will try this out.
N

"Phillip Williams" wrote:
我将有一个方法订阅数据源
对象的Selected事件,以保存在私有变量中检索的总记录,例如
void DataSource1_Selected(object sender,ObjectDataSourceStatusEventArgs
e)
{
iTotalRecords =((DataView)e.ReturnValue).Count;
}

然后我会订阅rowCreated事件来编写来自
pageIndex,pageSize和总记录数的消息,例如

void GridView1_RowCreated(object sender,GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.Pager)
{
标签lbl = new Label();
//编译标签文本
lbl.Text =查看记录 +(GridView1.PageIndex *
GridView1.PageSize)+1 +" - +((GridView1.PageIndex + 1)*
GridView1.PageSize)+" 的+ iTotalRecords;
//注意,寻呼机模板渲染了一个单元格,其中有一个HTMLTable
e.Row.Cells [0] .Controls.Add(lbl);
}
}
我没有运行这段代码,你可能需要调试其中的任何拼写错误,但它应该给你这个想法。 />
-
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp .com

" NH"写道:
I would have a method subscribing to the Selected event of the datasource
object to save total record retrieved in a private variable, e.g.

void DataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs
e)
{
iTotalRecords = ((DataView)e.ReturnValue).Count;
}

Then I would subscribe to the rowCreated event to compose a message from the
pageIndex, pageSize and the total records count, e.g.

void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType==DataControlRowType.Pager)
{
Label lbl= new Label();
//compse the label text
lbl.Text="Viewing records " + (GridView1.PageIndex *
GridView1.PageSize) +1 + " - " + ((GridView1.PageIndex+1) *
GridView1.PageSize) +" of " + iTotalRecords ;
//notice that the pager template renders one cell in which
//there is an HTMLTable
e.Row.Cells[0].Controls.Add(lbl);
}
}

I haven''t run this code, you might have to debug any typos in it, but it
should give you the idea.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"NH" wrote:
我有一个启用分页的girdview。如何在页脚中添加消息
说查看记录1-15 of 45。等

谢谢
I have a girdview with paging enabled. How can I add a message in the footer
to say "Viewing records 1-15 of 45" etc

Thanks



这篇关于gridview:“查看y的记录x”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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