数据绑定:
private void GridDataBind()
{
SqlHelper db = new SqlHelper();
db.Open();
SqlCommand Cmd = new SqlCommand();
Cmd.Connection = db.con;
Cmd.CommandTimeout = 60;
Cmd.CommandType = CommandType.Text;
string sql = "select ID ,USER ,USER_TYPE,USER_LAND,REAL_NAME,PHONENO,ACTIVED from MD_USER where USER is not null "
Cmd.CommandText = sql;
SqlDataAdapter str = new SqlDataAdapter(Cmd);
DataTable table = new DataTable();
str.Fill(table);
this.GridView1.DataSource = table;
this.GridView1.DataBind();
db.Close();
}
GridView1.DataSource:负责与数据源的交互,将检索出来的数据绑定到GridView中显示
GridView1.DataBind:将数据源绑定到GridView控件.