只有BoundColumn列和自动生成列,才可以通过TableCell.Text属性读取显示的文本,例如:
e.Item.Cells(i).Text '其中Item表示当前行,cell表示列
如果是模版列,可以用findcontrol方法,例如:
TextBox txt = (TextBox)DataGrid1.Items[1].FindControl("txtID"); //c#
或
Dim lb As New Label()
...
'根据经验在一般情况下,没有id的label控件为Controls(1)
lb = CType(e.Item.Cells(i).Controls(1), Label)
If lb.Text = "0" Then
lb.Text = ""
End If