ASP.NET 扩展 gridview 以在 gridview 下方显示导航栏?

发布于 2024-10-02 23:38:49 字数 850 浏览 7 评论 0原文

我开发了一个继承自 gridview 的 asp.net 控件,它被称为 gridviewex...我需要一些页面导航内容在它下面呈现,以用于我正在实现的一些自定义分页..一切顺利,但我似乎无法向控件添加新控件。

例如,我想做的是在网格下方添加一个 asp.net 面板,然后向面板添加链接按钮。

到目前为止我已经有了这个,但它给出了一个错误

  Unable to cast object of type 'System.Web.UI.WebControls.Panel' to type 
  'System.Web.UI.WebControls.Table'.

代码..

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        Panel uxGridViewNavigation = new Panel();

        LinkButton linkButton = null;

        linkButton = new LinkButton();
        linkButton.Text = "First";
        linkButton.Click += new EventHandler(linkButton_Click);

        uxGridViewNavigation.Controls.Add(linkButton);

        this.Controls.Add(uxGridViewNavigation);

     }

我真的很感激任何帮助。这是我的第一个服务器控制扩展:-)

谢谢

I have developed an asp.net control that inherits from the gridview and its called gridviewex... i need some page navigation stuff to render underneath it for some custom paging that i am implenting.. All going well but i can't seem to add new controls to the controls..

For example what i wanted to do is add a asp.net Panel underneath the grid and than add linkbuttons to the panel.

I have this so far but it gives an error

  Unable to cast object of type 'System.Web.UI.WebControls.Panel' to type 
  'System.Web.UI.WebControls.Table'.

The code..

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        Panel uxGridViewNavigation = new Panel();

        LinkButton linkButton = null;

        linkButton = new LinkButton();
        linkButton.Text = "First";
        linkButton.Click += new EventHandler(linkButton_Click);

        uxGridViewNavigation.Controls.Add(linkButton);

        this.Controls.Add(uxGridViewNavigation);

     }

I would really appreciated any help. Its my first server control extension :-)

Thanks

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

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

发布评论

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

评论(1

你另情深 2024-10-09 23:38:49

重写Render,如下所示:

override Render(HtmlTextWriter writer)
{
    // outputs all the inner magic of your grid
    base.Render(writer);

    Panel panel = new Panel();
    // do magic

    // now also render the panel to the writer
    panel.RenderControl(writer);
}

Override Render like:

override Render(HtmlTextWriter writer)
{
    // outputs all the inner magic of your grid
    base.Render(writer);

    Panel panel = new Panel();
    // do magic

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