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

  • 相关阅读:
    iOS之地理位置及定位系统 -- 入门笔记(用Swift)
    网易新闻iOS版使用的18个开源组件
    自学 iOS – 三十天三十个 Swift 项目
    iOS之UI--富文本总结
    IOS开发--横向流水布局实现
    IOS开发--仿制网易新闻
    Runtime 方法替换 和 动态添加实例方法 结合使用
    写给IOS开发工程师的网页前端入门笔记
    Runtime(动态添加属性)
    const,static,extern简介(重要)
  • 原文地址:https://www.cnblogs.com/attilax/p/15199994.html
Copyright © 2011-2022 走看看