<EmptyDataTemplate>
<asp:DropDownList ID="ddlRateCode" runat="server" DataSourceID="odsRateCode" DataTextField="RateCode"
DataValueField="RateCodeID" SelectedValue='<%# Bind("RateCodeID") %>'>
</asp:DropDownList>
</EmptyDataTemplate>
答案 0 :(得分:3)
尝试强制手动DataBind()
像这样:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.EmptyDataRow)
{
DropDownList ddl = (DropDownList)e.Row.FindControl("ddlRateCode");
if (ddl != null)
{
ddl.DataBind();
}
}
}