以编程方式在GridView页面之间移动不起作用 [英] Moving Between GridView Pages Programmatically doesn't work

查看:69
本文介绍了以编程方式在GridView页面之间移动不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了新的ASP GridView并在没有选择DataSource的情况下对其进行了自定义.
并创建SqlDataSource(定义连接字符串,参数).
然后以编程方式在我的.CS文件中分配GridView数据源..效果很好.

但是,当在GridView页面之间移动时,gridview消失并且什么也不做...

I created new ASP GridView and customize it without select DataSource.
and create SqlDataSource (define connectionstring, parameters) .
then assign GridView DataSource programmatically in my .CS File .. and it''s work very well.

But when moving between GridView Pages the gridview disappear and do nothing...

<asp:GridView ID="gridAdminRoles" runat="server"

DataKeyNames="RoleID" CellPadding="4"

ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"

ShowFooter="True" Width="100%" AllowPaging="True" PageSize="7"

onpageindexchanging="gridAdminRoles_PageIndexChanging" >

<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />

<Columns>
<asp:BoundField DataField="RoleID" HeaderText="RoleID" />
<asp:BoundField DataField="RoleName" HeaderText="Name" />
<asp:BoundField DataField="BranchName" HeaderText="Branch" />


</Columns>
</asp:GridView>





<asp:SqlDataSource ID="RolesDataSource" runat="server"

                 ConnectionString="<%$ ConnectionStrings:ShareCon %>"

                 SelectCommand="GetBranchesRoles"

                 SelectCommandType="StoredProcedure" >
                </asp:SqlDataSource>



在Page_Load()事件中...



In Page_Load() Event...

gridAdminRoles.DataSource = RolesDataSource;
gridAdminRoles.DataBind();



所有这些都能正常工作| ^ |

现在我想在gridview的页面之间移动,所以我将此代码写入PageIndexChanging,但是GridView消失了...



All of this working properly |^|

Now i want moving between pages of gridview So i wrote this code into PageIndexChanging but the GridView Disappear ...

protected void gridAdminRoles_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gridAdminRoles.PageIndex = e.NewPageIndex;
    gridAdminRoles.DataBind();
}

推荐答案

ConnectionStrings:ShareCon %> " span> =" GetBranchesRoles" span> =" StoredProcedure" > < /asp:SqlDataSource >
ConnectionStrings:ShareCon %>" SelectCommand="GetBranchesRoles" SelectCommandType="StoredProcedure" > </asp:SqlDataSource>



在Page_Load()事件中...



In Page_Load() Event...

gridAdminRoles.DataSource = RolesDataSource;
gridAdminRoles.DataBind();



所有这些都能正常工作| ^ |

现在我想在gridview的页面之间移动,所以我将此代码写入PageIndexChanging,但是GridView消失了...



All of this working properly |^|

Now i want moving between pages of gridview So i wrote this code into PageIndexChanging but the GridView Disappear ...

protected void gridAdminRoles_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gridAdminRoles.PageIndex = e.NewPageIndex;
    gridAdminRoles.DataBind();
}


protected void gridAdminRoles_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gridAdminRoles.PageIndex = e.NewPageIndex;

    //Set Datasource
    gridAdminRoles.DataSource = RolesDataSource;

    gridAdminRoles.DataBind();
}.


这篇关于以编程方式在GridView页面之间移动不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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