【问题标题】:Dropdownlist in gridview's EmptyDataTemplate is not populatinggridview 的 EmptyDataTemplate 中的下拉列表未填充
【发布时间】:2010-02-01 06:31:19
【问题描述】:
<EmptyDataTemplate>
                  <asp:DropDownList ID="ddlRateCode" runat="server" DataSourceID="odsRateCode" DataTextField="RateCode"
                        DataValueField="RateCodeID" SelectedValue='<%# Bind("RateCodeID") %>'>
                    </asp:DropDownList>
   </EmptyDataTemplate>

【问题讨论】:

标签: asp.net gridview


【解决方案1】:

尝试手动强制 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();
            }
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-30
    • 2022-01-19
    相关资源
    最近更新 更多