如何有条件地禁用Gridview中的项模板字段?

时间:2015-10-17 11:51:59

标签: c# asp.net gridview

private void hidePartPayment()
{
    foreach (GridViewRow row in invoices.Rows)
    {
        var cb = (CheckBox)row.FindControl("Check");
        if (!cb.Enabled)
        {
            //row.Cells[12]. this is not working
            row.Cells[12].Enabled = false;   
        }
    }
}

我在gridview上有一个弹出窗口,我想根据上面的条件禁用链接(不可点击)但是不起作用。

1 个答案:

答案 0 :(得分:1)

你调试了代码吗?你的代码是否达到了目的

row.Cells[12].Enabled = false;

然后请快速查看专栏row.Cells[12]。可能是你指向的行不正确。

相关问题