namespace Exercise1.DepMng
{
public partial class UserM2 : System.Web.UI.Page
{
Helper he = new Helper();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
public void Bind()
{
string user_sql = "select * from User";
DataSet ds = he.GetDataSet(user_sql, "User");
GridView1.DataSource = ds;
GridView1.DataKeyNames = new string[] { "UserID" };
GridView1.DataBind();
//设Θ?置? DropDownList默?认?值μ
DropDownList ddl;
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
DataRowView mydrv = ds.Tables[0].DefaultView[i];
ddl = (DropDownList)GridView1.Rows[i].FindControl("depList");
ddl.SelectedValue = ds.Tables[0].Rows[i]["DepId"].ToString();
ddl = (DropDownList)GridView1.Rows[i].FindControl("roleList");
ddl.SelectedValue = ds.Tables[0].Rows[i]["RId"].ToString();
}
}
public DataSet ddlbind()
{
string sql = "select * from Department";
DataSet ds = he.GetDataSet(sql, "Department");
return ds;
}
评论1