Gridview PageIndexChanging事件未触发

时间:2013-02-01 10:55:01

标签: asp.net gridview user-controls page-index-changed

我在usercontrol中有一个gridview

 <asp:GridView ID="grdMissingFilterData" runat="server"   AllowPaging="True" Width="100%"
                        AllowSorting="True" AutoGenerateColumns="False" GridLines="None"
                        PageSize="30" OnPageIndexChanging="grdMissingFilterData_PageIndexChanging">
                        <Columns>
                            <asp:BoundField DataField="Varenummer" HeaderText="Varenummer"   ItemStyle-Width="25%" >
                            <ItemStyle Width="25%" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Varenavn" HeaderText="Varenavn"  ItemStyle-Width="15%" >
                            <ItemStyle Width="15%" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Producentvarenummer" HeaderText="Producent varenummer"  ItemStyle-Width="15%" >
                            <ItemStyle Width="15%" />
                            </asp:BoundField>
                        </Columns>
                        <AlternatingRowStyle CssClass="altrow" />
                        <PagerSettings FirstPageText="First" LastPageText="Last" PageButtonCount="50" />
                        <EmptyDataTemplate>
                            There is no data available to display!
                        </EmptyDataTemplate>
   <PagerStyle CssClass="pager" />
    </asp:GridView>

和回发中的代码

if (!Page.IsPostBack)
    {  
        BindData(); 
    }

然后我有一个PageIndexChanging事件,当我点击分页时它永远不会触发。

 protected void grdMissingFilterData_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    grdMissingFilterData.PageIndex = e.NewPageIndex;
    BindData();
}

任何人都可以给我任何可能的理由吗?

1 个答案:

答案 0 :(得分:2)

这可能是您的用户控件不是关于gridview的问题。 专注于那部分