【发布时间】:2017-02-23 15:06:15
【问题描述】:
【问题讨论】:
【问题讨论】:
您可以像这样使用 GridViewRowDataBound 事件来做到这一点。
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Try This
DropDownlist ddl =((DropDownList)e.Row.FindControl("ddlUOM"));
Label lblCargo = ((Label)e.Row.FindControl("lblNameOfCargo"));
if(ddl.SelectedValue == "Barrel")
{
lblCargo.Text = "test";
}
}
}
【讨论】:
在 ddl 的选定索引更改事件上尝试这样的操作。
DropDownList ddlUOM = (DropDownList)sender;
GridViewRow rpItem = ddlUOM .NamingContainer as GridViewRow;
Label lblCargo = ((Label)rpItem.FindControl("lblNameOfCargo"));
if(ddlUOM.SelectedValue == "Barrel")
{
lblCargo.Text = "test";
}
【讨论】: