【问题标题】:Bind gridview inside of usercontrol from content page从内容页面绑定用户控件内的gridview
【发布时间】:2010-07-13 22:11:04
【问题描述】:

您好,是否可以从内容页面绑定用户控件内的 gridview,如果可以,如何?

【问题讨论】:

    标签: c# asp.net linq linq-to-entities


    【解决方案1】:

    是的,最简单的方法是在用户控件中公开绑定,然后从您的页面调用它。

    //in user control, add this method
    public void BindGrid()
    {
        gvInnerGrid.DataBind();
    }
    
    //on your page
    userControl.BindGrid();
    

    【讨论】:

    • 您好,谢谢。我需要传递 IQueryable 对象才能将 GridView 与数据绑定。然后在用户控件内部查询这个对象。你知道怎么做吗?
    • 您可以使用相同的方法来传递数据。就个人而言,我会在用户控件上创建一个公共属性,以公开网格的 DataSource。前任。 //用户控件公共对象DataSource{get{return gvInnerGrid.DataSource;} set {gvInnerGrid.DataSource = value;}}
    猜你喜欢
    • 2011-12-25
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    • 2019-05-07
    • 2014-10-18
    • 2014-01-14
    • 1970-01-01
    • 2010-09-27
    相关资源
    最近更新 更多