【发布时间】:2014-05-22 14:40:34
【问题描述】:
我有一个 datagrid dgCompanies 声明如下:
// bind the data to the datagrid
dgCompanies.PageSize = pageSize;
dgCompanies.DataSource = rdr;
然后我需要检查这个datagrid里面的记录:
int j = 0;
foreach (DataGridItem item in dgCompanies.Items)
{
HtmlGenericControl name = (HtmlGenericControl)item.Cells[j].FindControl("SpanTitle");
string drstring = name.InnerHtml.Trim();
if (checkingfunction(drstring))
{
//do removing record from datagrid.
I tried this: item.Cells.Remove(item.Cells[j]); but the result still there, don't see anything removed!
}
j = j + 1;
}
dgCompanies.DataBind();
如果条件满足,我如何从数据网格dgCompanies 中删除该记录?
【问题讨论】:
-
过滤数据源不是更简单更自然吗?
-
我认为这并不容易,请在这里参考我的问题:stackoverflow.com/questions/23774851/…
-
我试过了:item.Cells.Remove(item.Cells[j]);但结果仍然存在,没有看到任何删除!