简体   繁体   English

在GridView中添加新行时绑定下拉列表

[英]Binding dropdownlist when adding a new row in gridview

我在gridview中有一个下拉列表和一些文本框,并且从数据库值中绑定了DDL,我必须添加具有相同DDL和文本框的新行,但是当创建新行时如何绑定DDL?

You can add the new row in GridView Footer. 您可以在GridView页脚中添加新行。 During RowDataBound event you can find the DDL and Bind the data, RowDataBound事件期间,您可以找到DDL并绑定数据,

protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.Footer)
    {
        DropDownList ddlName= (DropDownList)e.Row.FindControl("dlstName");
        // You can bind data to ddlName
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM