DataTable的使用。(将数据列信息赋值给指定的控件)

string str="select * from pe_production where id='"+TextBox23.Text.Trim()+"'";
tb=updata.ExecuteSql4Ds(str).Tables[0];
if (tb.Rows.Count>0)
{
     BindDropDownList1();//从数据库中绑定数据,删除此行,必须手动绑定DropDownList1中信息
     TextBox1.Text=tb.Rows[0][2].ToString().Trim();
     TextBox3.Text=tb.Rows[0][5].ToString().Trim();
     string DropDown1=tb.Rows[0][3].ToString().Trim();
     for (int i=0;i<DropDownList1.Items.Count;i++)
        {
            if (DropDownList1.Items[i].ToString().Trim() == DropDown1)                                     
              {
                  DropDownList1.SelectedIndex = i;
                  BindDropDownList2();
                  BindDropDownList3();
                  break;
              }
        }
}

你可能感兴趣的:(Datatable)