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();
            }


        }

  • 相关阅读:
    梯度下降优化算法
    【网站管理6】_一个网站SEO优化方案
    25条div+CSS编程提醒及小技巧整理
    100多个基础常用JS函数和语法集合大全
    Understanding Built-In User and Group Accounts in IIS 7
    【网站seo优化】SEO优化每天的工作内容是什么?
    如何实现织梦dedecms表单提交时发送邮箱功能【已解决】
    【织梦dedecms安全设置】dedecms如何防止被黑?dedecms被黑了怎么办?
    【dedecms网站安全】如何防止dedecms网站被DDos攻击
    【织梦dedecms系统安全】完善DEDECMS目录的权限安全设置
  • 原文地址:https://www.cnblogs.com/huhu456/p/1453414.html
Copyright © 2011-2022 走看看