当前位置: 代码迷 >> ASP.NET >> 下拉列表框有关问题
  详细解决方案

下拉列表框有关问题

热度:5942   发布时间:2013-02-25 00:00:00.0
下拉列表框问题
明细表是datagrid,物料编码用的是ddl,页面初始时从数据库查询出数据绑定,希望下拉选择不同编码时,把物料的描述和价格等信息赋值到datagrid中的其它列,具体怎么做,谢谢!

------解决方案--------------------------------------------------------
在edit事件的时候,帮定你的物料编码
protected void gridview_RowEditing(object sender, GridViewEditEventArgs e)
{
int id = Convert.ToInt32(GridView1.DataKeys[e.NewEditIndex].Value);
bindeddl(id);

}
private void bindeddl(int x)
{
string str = "select * from zuoyue_companey"
DataSet dss = DbHelperSQL.Query(str);
DataView dv = dss.Tables[0].DefaultView;
((DropDownList)GridView1.Rows[x].FindControl("DropDownList2")).DataSource = dss;
((DropDownList)GridView1.Rows[x].FindControl("DropDownList2")).DataTextField = "companey_name";
((DropDownList)GridView1.Rows[x].FindControl("DropDownList2")).DataValueField = "companey_id";
((DropDownList)GridView1.Rows[x].FindControl("DropDownList2")).DataBind();

}
一个gridview例子给你参考
------解决方案--------------------------------------------------------
问题不难,能不能说详细点
------解决方案--------------------------------------------------------
在你的ddl的SelectIndexChanged事件里面写不行吗?根据你选中的值为条件去查询,完了进行dataGrid邦定
------解决方案--------------------------------------------------------
up
------解决方案--------------------------------------------------------
设不同的value啊
string s = DropDownList1.SelectedValue.ToString();

switch (s)
{
case "111":
...
break;
case "222":
...
break;
case "333":
...
break;
}
  相关解决方案