日期:2014-05-18  浏览次数:20825 次

怎样把联动下拉菜单放到ASPxGridView里使用
用ASPxGridView控件来完成录入数据功能,但是有两个字段是选择单位,二级联动(从另一个数据表中取得的),后台有事件,怎样放到ASPxGridView里使用并保存到ASPxGridView所连的数据表里,数据表有对应的单位字段。谢谢

------解决方案--------------------
查出来的 先绑定到ASPxGridView 然后在insert into 表 里面不行吗?
------解决方案--------------------
看内容 就是上面的意思 看问题 就不知道你说啥了
------解决方案--------------------
循环遍历查找或者在
GridView_RowDataBound
protected void gdv_Elec_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (((DropDownList)e.Row.FindControl("drop_Location")) != null)
{
DropDownList drop_Location = (DropDownList)e.Row.FindControl("drop_Location");
drop_Location.Items.Clear();
DataTable dt = ef.GetLocation();
drop_Location.DataSource = dt;
drop_Location.DataTextField = dt.Columns["LOCATION"].ToString();
drop_Location.DataValueField = dt.Columns["LOCATION"].ToString();
drop_Location.DataBind();
}
}

protected void drop_Location_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList drop_Location = (DropDownList)sender;
System.Web.UI.WebControls.GridViewRow dvr = (System.Web.UI.WebControls.GridViewRow)drop_Location.NamingContainer;
DropDownList drop_name = (DropDownList)dvr.FindControl("drop_name");
//drop_name.Items.Clear();
DataTable dt = ef.GetNameBYLocation(drop_Location.SelectedItem.Text);
drop_name.DataSource = dt;
drop_name.DataTextField = dt.Columns["ECLE_NAME"].ToString();
drop_name.DataValueField = dt.Columns["ECLE_NAME"].ToString();
drop_name.DataBind();
}
------解决方案--------------------
或者在编辑事件中查找
protected void gvRequestRoleList_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//获得DropDownList 控件
DropDownList ddlRequestRole = gvRequestRoleList.Rows[e.RowIndex].Cells[5].FindControl("ddlRequestRole") as DropDownList;
string roleName = ddlRequestRole.SelectedItem.Value;
\\
另外查找方法
string xueli = ((DropDownList)gvRequestRoleList.Rows[e.RowIndex].FindControl("ddlRequestRole")).SelectedValue;