zoukankan      html  css  js  c++  java
  • 控件绑定类

    在开发中,查找数据后经常需要绑定某些控件。下面是在日常开发中我们经常需要绑定的控件,闲话少说见如下代码。

    //DataList

    public void DtListBind<T>(DataList TmpDtList, IList<T> Tmp) {
            TmpDtList.DataSource = Tmp;
            TmpDtList.DataBind();
        }

        protected void GrVwBind<T>(GridView TmpGrVw, IList<T> Tmp) {
            TmpGrVw.DataSource = Tmp;
            TmpGrVw.DataBind();
        }

    //DropDownList
        public void BindDropDownList<T>(DropDownList TmpDrop, IList<T> Tmp, string IdName, string Name) {
            TmpDrop.DataSource = Tmp;
            TmpDrop.DataTextField = Name;
            TmpDrop.DataValueField = IdName;
            TmpDrop.DataBind();

        }

     //RadioButtonList
       protected void BindRadioButtonList<T>(RadioButtonList TmpBtn, IList<T> Tmp, string IdName, string Name) {
            TmpBtn.DataSource = Tmp;
            TmpBtn.DataTextField = Name;
            TmpBtn.DataValueField = IdName;
            TmpBtn.DataBind();
        }

    //ListBox

        protected void BindListBox<T>(ListBox TmpCtr, IList<T> Tmp, string IdName, string Name) {
            TmpCtr.DataSource = Tmp;
            TmpCtr.DataTextField = Name;
            TmpCtr.DataValueField = IdName;
            TmpCtr.DataBind();
        }

    //CheckBoxList

        protected void BindCheckBoxList<T>(CheckBoxList TmpCtr, IList<T> Tmp, string IdName, string Name) {
            TmpCtr.DataSource = Tmp;
            TmpCtr.DataValueField = IdName;
            TmpCtr.DataTextField = Name;

            TmpCtr.DataBind();
        }

    //GridView
        protected void GridViewBind(GridView DBView, DataTable Table) {
            DBView.DataSource = Table;
            DBView.DataBind();
        }

    //DataList

        protected void ListBind(System.Web.UI.WebControls.DataList DbList, System.Data.DataTable SrcTable) {
            DbList.DataSource = SrcTable;
            DbList.DataBind();
        }

    //DataTable 

        protected void BindDropDownList(DataTable tmpTB, string str_Text, string str_Value, DropDownList myDropDownList) {
            if (tmpTB != null) {
                DataRow tmpRow = tmpTB.NewRow();
                myDropDownList.DataSource = tmpTB.DefaultView;
                myDropDownList.DataValueField = str_Value;
                myDropDownList.DataTextField = str_Text;
                myDropDownList.DataBind();
            }
            else {
                myDropDownList.Items.Clear();
            }


        }

  • 相关阅读:
    洛咕11月月赛部分题解 By cellur925
    POJ 2411 Mondriaan's Dream 【状压Dp】 By cellur925
    Luogu P1637 三元上升子序列【权值线段树】By cellur925
    Luogu P1438无聊的序列【线段树/差分】By cellur925
    Luogu P1558 色板游戏【线段树/状态压缩】By cellur925
    Luogu P4403 [BJWC2008]秦腾与教学评估【二分答案】By cellur925
    Luogu P3941 入阵曲【前缀和】By cellur925
    查询事件状态,mysql查看事件是否开启,设置启动时自动开启方法
    Logback详细整理,基于springboot的日志配置
    使用release自动打包发布正式版详细教程
  • 原文地址:https://www.cnblogs.com/huhu456/p/1453414.html
Copyright © 2011-2022 走看看