GridView 分页器模板内的访问控制 - ASP.NET

发布于 2024-08-17 03:53:15 字数 313 浏览 2 评论 0原文

我正在尝试访问 GridView 中 PagerTemplate 内的 LinkBut​​ton。

但是,我收到 NullReferenceException 并且我不知道我在这里做错了什么。

我已经尝试过以下操作...

((LinkButton)GridView1.BottomPagerRow.FindControl("lnkbtnPrevious"));
((LinkButton)GridView1.FindControl("lnkbtnPrevious"));

有人可以帮忙吗?

谢谢!

I am trying to access a LinkButton that is inside a PagerTemplate in a GridView.

However, I am getting a NullReferenceException and I don't know what I am doing wrong here.

I have tried the following...

((LinkButton)GridView1.BottomPagerRow.FindControl("lnkbtnPrevious"));
((LinkButton)GridView1.FindControl("lnkbtnPrevious"));

Can someone please help?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

回心转意 2024-08-24 03:53:15
GridViewRow PagerRow = GridView1.BottomPagerRow;
LinkButton b = (LinkButton)PagerRow.FindControl("lnkbtnPrevious"));
GridViewRow PagerRow = GridView1.BottomPagerRow;
LinkButton b = (LinkButton)PagerRow.FindControl("lnkbtnPrevious"));
小耗子 2024-08-24 03:53:15

确保您已经在 PagerTemplate 中创建了 ID 为“lnkbtnPrevious”且 PagerSettings Position=“Bottom”的链接按钮,以下内容将使您能够访问该链接按钮。

LinkButton lb = (LinkButton)((GridView1.BottomPagerRow).FindControl("lnkbtnPrevious"));

Make sure you have already created the link button in the PagerTemplate with the ID "lnkbtnPrevious" and the PagerSettings Position="Bottom" the following will get you access to the link button.

LinkButton lb = (LinkButton)((GridView1.BottomPagerRow).FindControl("lnkbtnPrevious"));
心的憧憬 2024-08-24 03:53:15

首先在pagertemplate中为gird创建一个链接按钮
并在 gridview 的数据绑定事件中的代码中给 id= "LB"

工作,

protected void grid_DataBound(object sender, EventArgs e)
{
 LinkButton lb = (LinkButton)grid.BottomPagerRow.FindControl("LB");
}

这将起作用

First create a link button in pagertemplate for gird
and give id= "LB"

work this in code in databound event of gridview

protected void grid_DataBound(object sender, EventArgs e)
{
 LinkButton lb = (LinkButton)grid.BottomPagerRow.FindControl("LB");
}

this will work

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文