0
我在ObjectDataSource
中有一些數據,在將數據綁定到GridView
之前,我想從DataSource
中刪除一些行。在綁定到gridview之前從objectdatasource刪除行
這就是我想:
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();
}
這不是工作,它不會過濾或刪除網格中的任何數據。任何想法如何做明確的刪除?
RowDataBound事件中刪除行的操作太舊,在綁定方法中應用您的刪除行代碼。發佈您的綁定代碼 – tdelepine
@tdelepine在編輯中添加了網格綁定 – faizanjehangir