gridview cells 取值的问题(急)
<PagerTemplate>
<asp:LinkButton ID="lbFirst" runat="server" CausesValidation="False" CommandArgument="First"
CommandName="Page">首页 </asp:LinkButton>
<asp:LinkButton ID="lbPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
CommandName="Page">上一页 </asp:LinkButton>
<asp:LinkButton ID="lbNext" runat="server" CausesValidation="False" CommandArgument="Next"
CommandName="Page">下一页 </asp:LinkButton>
<asp:LinkButton ID="lbLast" runat="server" CausesValidation="False" CommandArgument="Last"
CommandName="Page">尾页 </asp:LinkButton> 第 <asp:Label ID="Label2"
runat="server" Text=" <%#((GridView)Container.Parent.Parent).PageIndex + 1 %>">
</asp:Label>页 共 <asp:Label ID="Label1" runat="server" Text=" <%# ((GridView)Container.Parent.Parent).PageCount %>">
</asp:Label>页 跳到<asp:TextBox ID="TextBox1" runat="server" Text=""></asp:TextBox>
<asp:LinkButton ID="lbGO" runat="server" CausesValidation="False" CommandArgument="-1" CommandName="Page" Text="GO" OnClick="GoIndex"> </asp:LinkButton>
</PagerTemplate>
后台
protected void GoIndex(object sender, EventArgs e)
{
GridViewRow pagerRow = GridView1.BottomPagerRow;
TextBox pageNum = pagerRow.Cells[0].FindControl("TextBox1") as TextBox;
int idx = 0;
if (pageNum.Text != null)
{
try
{
idx = Int32.Parse(pageNum.Text);
}
catch
{
}
}
GridView1.PageIndex = idx > 0 ? idx - 1 : 0;
}
为什么文本框里的值是空,空了怎么还能进if里,我都反复看了很多遍, 感觉没问题,但是现在真是找不出来了!请大家帮帮忙 速度给我看看啊!