if (dt.Rows.Count > 0)求注释

1个回答

  • string id = Request["ID"].ToString(); //页面传递来的id参数

    try

    {

    string sql = "select * from TB_MeiShi where ID=" + id; // 数据库查询语句 .

    DataTable dt = DBHelper.GetDataSet(sql).Tables[0];//执行sql语句从数据库中读取数据并填充在dt

    if (dt.Rows.Count > 0)//dt里有数据,则进行数据填充

    {

    this.TextBox1.Text = dt.Rows[0]["MingCheng"].ToString(); 查询结果的第一行的MingCheng赋值给textbox1

    this.DropDownList1.Text = dt.Rows[0]["CaiXi"].ToString();

    this.WebEditor1.Text = dt.Rows[0]["JieShao"].ToString();

    }

    }