gridview cells 取值的问题(急)

quanpp_user 2009-03-17 04:57:22
<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里,我都反复看了很多遍, 感觉没问题,但是现在真是找不出来了!请大家帮帮忙 速度给我看看啊!
...全文
65 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
quanpp_user 2009-03-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zl35377345 的回复:]
if (pageNum.Text != "")
{
try
{
idx = Int32.Parse(pageNum.Text);
}
catch
{
}
}
这样试试,行不行
[/Quote]

关键是文本框值是空的啊 主要问题是在这啊
zl35377345 2009-03-17
  • 打赏
  • 举报
回复
if (pageNum.Text != "")
{
try
{
idx = Int32.Parse(pageNum.Text);
}
catch
{
}
}
这样试试,行不行

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧