我正在使用 gridview 控件来显示记录。 我希望从数据源显示前 6 条记录。 其余行(仅适用于 COL2 和 COL4)应替换为问号字符
类似这个。
COL1 COL2 COL3 COL4 COL5
row1 row1 row1 row1 row1
row2 row2 row2 row2 row2
...
...
row6 row6 row6 row6 row6
row7 ? row7 ? row7
row8 ? row8 ? row8
row9 ? row9 ? row9
最佳答案
您可以使用RowIndex
RowDataBound
中的 GridViewRow
将单元格文本更改为 ?
:
protected void gridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if(e.Row.RowIndex > 5)
{
e.Row.Cells[1].Text = "?";
e.Row.Cells[3].Text = "?";
}
}
}
关于c# - 如何在 6 条记录后用 "question mark character"替换 gridview 的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13103990/