本文介绍了在editmode中的网格时填充下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)

{



if(e.Row.RowType == DataControlRowType.DataRow )

{

if((e.Row.RowState&DataControlRowState.Edit)> 0)

{

DataRowView drv = e.Row.DataItem as DataRowView;

DropDownList ddlnric =(DropDownList)e.Row.FindControl(ddlnric);

string query =从Employeesms中选择DISTINCT ecode;

SqlCommand cmd = new SqlCommand(query);

ddlnric.DataSource = GetData(cmd);

ddlnric .DataTextField =ecode;

ddlnric.DataValueField =ecode;

ddlnric.DataBind();

ddlnric.SelectedValue = drv [lblcode]。ToString();

}

}

}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
DataRowView drv = e.Row.DataItem as DataRowView;
DropDownList ddlnric = (DropDownList)e.Row.FindControl("ddlnric");
string query = "select DISTINCT ecode from Employeesms";
SqlCommand cmd = new SqlCommand(query);
ddlnric.DataSource = GetData(cmd);
ddlnric.DataTextField = "ecode";
ddlnric.DataValueField = "ecode";
ddlnric.DataBind();
ddlnric.SelectedValue = drv["lblcode"].ToString();
}
}
}

推荐答案

这篇关于在editmode中的网格时填充下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 15:33