0

我有一些数据ObjectDataSource,在将数据绑定到 之前GridView,我想从DataSource.

这就是我正在尝试的:

protected void gvExitInterview_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            User employee = (User) e.Row.DataItem;

            if(//some condition here)
            {
                //do nothing
            }
            else
            {
                //delete the row
                this.gv.DeleteRow(e.Row.RowIndex);
                return;
            }
}
}

这些是我的删除方法:

protected void gvExitInterview_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }


    protected void gvExitInterview_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {
        gv.DataBind();
    }

这是我的网格绑定:

private void BuildGrid(DateTime from, DateTime to)
    {
        this.objDS.TypeName = "EmployeeManagement";
        this.objDS.SelectMethod = "GetEmployees";
        this.objDS.SelectCountMethod = "GetEmployeesCount";
        this.objDS.SelectParameters.Clear();
        this.objDS.SelectParameters.Add("from", from.ToString());
        this.objDS.SelectParameters.Add("to", to.ToString());
        this.objDS.SelectParameters.Add("csvEntities", csv);
        this.objDS.SelectParameters.Add("sortExpression", ViewState["SortColumn"].ToString());
        this.gv.DataSource = objDS;
        this.gv.DataBind();
    }

这不起作用,它不会过滤或删除网格中的任何数据。知道如何进行显式删除吗?

4

1 回答 1

0

我认为您需要在 DataObjectClass 中编写另一个 SelectMethod 来获取您使用传递给过滤条件的参数。这样只需返回显示所需的行。

于 2013-10-22T14:04:24.387 回答