首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

接着刚才的有关问题,ASPxGridView的编辑模板

2012-09-14 
接着刚才的问题,ASPxGridView的编辑模板接着刚才的问题,把DropDownList放到ASPxGridView的编辑模板里,录入

接着刚才的问题,ASPxGridView的编辑模板
接着刚才的问题,把DropDownList放到ASPxGridView的编辑模板里,录入数据时候用,为什么就找不到DropDownList了,怎么解决。谢谢

[解决办法]
循环遍历查找或者在 
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();
}

热点排行