gridview模板中的“数据绑定”下拉列表

gridview模板中的“数据绑定”下拉列表,gridview,drop-down-menu,limit,databound,Gridview,Drop Down Menu,Limit,Databound,我需要根据gridview中该行另一列中的文本限制gridview中模板列中放置的数据绑定下拉列表中的值。我还希望下拉列表是数据绑定的。另外,这两件事不可能同时发生,因为它会导致数据绑定错误。我认为.net阻止它是因为数据库中可能会出现一个下拉列表中不存在的有效值 我如何使用下拉列表或任何其他方法来实现这一点 请提供帮助。您可以根据右侧文本框中输入的值过滤要显示的数据,从而限制数据绑定下拉列表的值 在事件grd_RowDataBound上放置ff:test代码 protected void gr

我需要根据gridview中该行另一列中的文本限制gridview中模板列中放置的数据绑定下拉列表中的值。我还希望下拉列表是数据绑定的。另外,这两件事不可能同时发生,因为它会导致数据绑定错误。我认为.net阻止它是因为数据库中可能会出现一个下拉列表中不存在的有效值

我如何使用下拉列表或任何其他方法来实现这一点


请提供帮助。

您可以根据右侧文本框中输入的值过滤要显示的数据,从而限制数据绑定下拉列表的值

在事件grd_RowDataBound上放置ff:test代码

protected void grd_RowDataBound(object sender, GridViewRowEventArgs e)
{
    TextBox txt = (TextBox)e.Row.FindControl("txt");
    DropDownList cbo = (DropDownList)e.Row.FindControl("cbo");

    if (cbo != null)
    {
        cbo.DataSource = _data.getData(txt.Text); //returns filterered datatable based on txt value
        cbo.DataTextField = "ListName";
        cbo.DataValueField = "ListID";
        cbo.DataBind();
    }
}

通过根据文本框右侧输入的值过滤要显示的数据,可以限制数据绑定下拉列表的值

在事件grd_RowDataBound上放置ff:test代码

protected void grd_RowDataBound(object sender, GridViewRowEventArgs e)
{
    TextBox txt = (TextBox)e.Row.FindControl("txt");
    DropDownList cbo = (DropDownList)e.Row.FindControl("cbo");

    if (cbo != null)
    {
        cbo.DataSource = _data.getData(txt.Text); //returns filterered datatable based on txt value
        cbo.DataTextField = "ListName";
        cbo.DataValueField = "ListID";
        cbo.DataBind();
    }
}