小弟学编程不久 请教各位大侠啊!
DEPT表
DEPT_ID int 部门编号
DEPT_NAME VARCHAR(50) 部门名称 EMP 表
ID NUMERIC(6) 序号
DEPT_ID int 所在部门 现在在员工管理页面 我选择一个员工将ID 通过URL 传到 员工修改页面
在修改页面有DropDownList 显示部门名称 我怎么默认选择这个员工所在部门啊????
小弟请教了 !!!
DEPT表
DEPT_ID int 部门编号
DEPT_NAME VARCHAR(50) 部门名称 EMP 表
ID NUMERIC(6) 序号
DEPT_ID int 所在部门 现在在员工管理页面 我选择一个员工将ID 通过URL 传到 员工修改页面
在修改页面有DropDownList 显示部门名称 我怎么默认选择这个员工所在部门啊????
小弟请教了 !!!
在查询用户信息,绑定到 DropDownList
DropDownList1.SeletedValue="";
DropDownList1.DataSource=ds;
DropDownList1.DataValueField="DEPT_ID";
DropDownList1.DataTextField="DEPT_NAME";
DropDownList1.DataBind();
DropDownList1.SelectedValue="";
if(!ispos````)
{
sting Id=Request.QueryString["id"]==null?"":Request.QueryString["id"].ToString();
bindDropDownList(Id)l;
}
private void bindDropDownList(string Id)
{
DropDownList1.DataSource=ds;
DropDownList1.DataValueField="DEPT_ID";
DropDownList1.DataTextField="DEPT_NAME";
DropDownList1.DataBind();
DropDownList1.SelectedValue=Id;
}
通过选中的Id值获得其部门名称!
3、dropdownlist选中
//选中
protected void btnChoose_Click(object sender, EventArgs e)
{
/*
* 1.通过FindByText方法;
* 2.通过FindByValue方法;
*/
BindDDL();
//1.通过FindByText方法;选择值为:72
DropDownList1.Items.FindByText("语文1").Selected = true;
//2.通过FindByValue方法;显示值为:语文2
//DropDownList1.Items.FindByValue("74").Selected = true;
}
ASP.NET DropDownList应用
if(!ispos````)
{
sting Id=Request.QueryString["id"]==null?"":Request.QueryString["id"].ToString();
bindDropDownList(Id);
}
private void bindDropDownList(string Id)
{
DropDownList1.DataSource=ds;
DropDownList1.DataValueField="DEPT_ID";
DropDownList1.DataTextField="DEPT_NAME";
DropDownList1.DataBind();
DropDownList1.SelectedValue=这里应该绑定的是通过ID到EMP表中查出来的dept_id;
}虽然 都不对 但也算咯
给分吧