分页gridview的图标问题 [英] problem with icons for paging gridview

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

问题描述

我的页面中有一个gridview和4个图像按钮(第一",上一个",下一个",最后一个"),似乎不太理想(例如,当我单击下一个图像"按钮时,它向我显示消息未找到记录") )

这是我的gridview的开始标签:

i have a gridview in my page and 4 imagebuttons (First, Previous, Next, Last) which seems to don''t work perfectly( when i click for example next imagebutton it shows me the message "no records was found")

this the begining tags o my gridview:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="UserID"

            AllowPaging="true" AllowSorting="true" EmptyDataText="No record was found" CellPadding="4"

            ForeColor="#333333" GridLines="None" PageSize="3">
            <PagerSettings Visible="false" />


这些是我的图像按钮


and these are my imagebuttons

<asp:Label ID="Label1" runat="server" BackColor="#FF8080" Text="Record Not Found"

Visible="False" Width="279px"></asp:Label>
<asp:ImageButton ID="ImageButton1" PostBackUrl="~/gridview.aspx" ImageUrl="~/images/ico_precedant.jpg"

OnClick="imgPageFirst_Command" runat="server" />
<asp:ImageButton ID="ImageButton2" PostBackUrl="~/gridview.aspx" ImageUrl="~/images/Arrow Left.bmp"

OnClick="imgPagePrevious_Command" runat="server" />
<asp:ImageButton ID="ImageButton3" PostBackUrl="~/gridview.aspx" ImageUrl="~/images/Arrow Right.bmp"

OnClick="imgPageNext_Command" runat="server" />
<asp:ImageButton ID="ImageButton4" PostBackUrl="~/gridview.aspx" ImageUrl="~/images/ico_suivant.jpg"

OnClick="imgPageLast_Command" runat="server" />


请注意,我的gridview和imagebutton都在updatepanel内
这些行是我的代码后面的行


Note that my gridview and the imagebuttons are all inside an updatepanel
and these lines are the lines of my code behind

Protected Sub imgPageFirst_Command(sender As Object, e As ImageClickEventArgs) Handles img_first.Click
       GridView1.PageIndex = 0
       GridView1.DataBind()
   End Sub
   Protected Sub imgPagePrevious_Command(sender As Object, e As ImageClickEventArgs) Handles img_previous.Click
       Dim i As Integer = GridView1.PageIndex - 1
       If GridView1.PageIndex <> 0 Then
           GridView1.PageIndex = i
       End If
       GridView1.DataBind()
   End Sub
   Protected Sub imgPageNext_Command(sender As Object, e As ImageClickEventArgs) Handles img_next.Click
       Dim i As Integer = GridView1.PageIndex + 1
       If GridView1.PageIndex < GridView1.PageCount Then
           GridView1.PageIndex = i
       End If
       GridView1.DataBind()
   End Sub
   Protected Sub imgPageLast_Command(sender As Object, e As ImageClickEventArgs) Handles img_last.Click
       GridView1.PageIndex = GridView1.PageCount
       GridView1.DataBind()
   End Sub

推荐答案

两件事.

1)当您再次对网格进行数据绑定时,您无需再次设置数据源属性.

2)标签控件的目的看起来不正确.为什么将gridview属性"EmptyDataText"设置为与标签相同的文本?如果没有用,请考虑去除标签.这可能是当前页面的标签,但未在您的代码中更新.
two things.

1) when you databind the grid again you are not setting the datasource property again.

2) The purpose of the label control does not look right. why have the gridview property "EmptyDataText" set to the same(ish) text as the label??? Consider removing label if not used for anything. This maybe a label for the current page but this is not being updated in your code.


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

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