我可以将操作应用于GridView的RowDataBound事件中的一系列单元格索引吗?

问题描述 投票:0回答:1

我根据特定单元格的内容在RowDataBound事件中设置GridView的布局功能

private void OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        if (e.Row.Cells[1].Text == " ")
        {
            e.Row.Cells[4].BackColor = System.Drawing.Color.White;
            e.Row.Cells[5].BackColor = System.Drawing.Color.White;
            e.Row.Cells[6].BackColor = System.Drawing.Color.White;

是否有方法指定必须对此操作应用的范围(单元格索引4到6?)>

类似:

private void OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        if (e.Row.Cells[1].Text == "&nbsp;" && e.Row.CellIndex >= 4 && e.Row.CellIndex <= 6)
        {
            e.Row.BackColor = System.Drawing.Color.White;

我根据特定单元格的内容在RowDataBound事件中设置GridView的布局功能私有void OnRowDataBound(Object sender,GridViewRowEventArgs e){if(e.Row.RowType == ...

c# asp.net gridview rowdatabound
1个回答
0
投票

这应该是您所需要的:

© www.soinside.com 2019 - 2024. All rights reserved.