zoukankan      html  css  js  c++  java
  • 编辑记录时 绑定记录DATATABLE到页面控件

     private void addrecord_Load(object sender, EventArgs e)
            {
                if (this.editid != 0)
                {

                    rec r = new rec();
                    DataTable dt = r.queryByid(editid);
                    Bind(dt);
                }
            }

            private void Bind(DataTable dt)
            {
                DataRow dr = dt.Rows[0];
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    DataColumn dc = dt.Columns[i];
                    bindTextboxValue(dc.ColumnName, dr[i].ToString());


                }
                //foreach (DataColumn dc in dr)
                //{
                //    dc.ToString();
                //}


                //  if (dt.Rows.Count == 0) return true;
            }

            private void bindTextboxValue(string name, string value)
            {

                foreach (Control con in this.Controls)
                {

                    //    if (!con.HasControls)
                    if (con is GroupBox)
                    {
                        foreach (Control con2 in con.Controls)
                        {
                            if (con2 is TextBox)
                            {
                                if (con2.Name.Equals(name))
                                    con2.Text = value;
                            }
                            //
                        }

                    }
                }
            }


            //bindTextboxValue

  • 相关阅读:
    leetcode
    leetcode: Path Sum II 迭代法
    leetcode : valid binary search tree
    地域划分 编程题
    n个整数中,找出尽可能多的数使他们组成一个等差数列,求最长等差数列的长度
    Nodejs 调试方法
    精心收集的48个JavaScript代码片段,仅需30秒就可理解
    React Native ref高级用法&&setNativeProps使用
    Git工作流指南:Gitflow工作流
    Git工作流指南:Pull Request工作流
  • 原文地址:https://www.cnblogs.com/attilax/p/15199994.html
Copyright © 2011-2022 走看看