• DataControlHelper


    public static class DataControlHelper

    {

    /// <summary>

    /// 绑定控件

    /// </summary>

    /// <param name="wc">要绑定的控件</param>

    /// <param name="dataSource">用于绑定的数据源</param>

    public static void Bind(WebControl wc, object dataSource)

    {

    if (wc is GridView)

    {

    GridView gv = wc as GridView;

    gv.DataSource = dataSource;

    gv.DataBind();

    }

    if (wc is DataList)

    {

    DataList dl = wc as DataList;

    dl.DataSource = dataSource;

    dl.DataBind();

    }

     

    if (wc is ListControl)

    {

    ListControl lc = wc as ListControl;

    //lc.Items.Clear();

    lc.DataSource = dataSource;

    lc.DataBind();

    if (dataSource is DbDataReader)

    {

    DbDataReader dr = dataSource as DbDataReader;

    dr.Close();

    }

    }

    }

    }

  • 相关阅读:
    【UR #17】滑稽树前做游戏
    chage
    [SDOI2016]储能表——数位DP
    password
    groupdel
    [NOI2017]泳池——概率DP+线性递推
    groupadd
    CF986C AND Graph
    userdel
    CF986C AND Graph
  • 原文地址:https://www.cnblogs.com/muyoushui/p/1903906.html
Copyright © 2020-2023  润新知