当值为1时,我希望将我的网格视图列的值更改为“active”。 我有一个类似于以下的网格视图列:
<asp:BoundField DataField="STATUS" HeaderText="STATUS" SortExpression="STATUS" HeaderStyle-HorizontalAlign="Left">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
</asp:BoundField>
和计算机科学代码
protected void gvCategory_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[5].Text=="0")
{
e.Row.Cells[5].Text = "INACTIVE";
}
}
}
这个代码实现是正确的,但是如果我更改了列的顺序,它就会出错。我需要像 findControl 函数一样的东西。谢谢。
GetCellByName
,它只应在标题行类型为e.Row.RowType == DataControlRowType.Header
时调用。 - David d C e Freitas