R
Rock
Isn't there a way to refer to a column in a datagrid by the name of the
column, rather than the index? This is a dynamically built datagrid, and
when I refer to dg.Column(0), it works fine, but if I refer to
dg.Column("ID"), I get an error saying the string format is incorrect. But
I don't always know what the column number is so I have to refer to it by
name:
With dg
.AutoGenerateColumns = "False"
.CellPadding="4"
.BackColor=Color.White
.BorderWidth = Unit.Pixel(3)
.GridLines=GridLines.Horizontal
.BorderStyle=BorderStyle.Double
.ShowHeader = true
.HeaderStyle.BackColor = Color.Black
.HeaderStyle.ForeColor = Color.White
.HeaderStyle.Font.Bold = true
.EditItemStyle.BackColor = Color.Silver
End With
Dim DGBoundColumnID as New BoundColumn
With DGBoundColumnID
.Visible=False
.DataField="ID"
.ReadOnly=True
End With
dg.Columns.Add(DGBoundColumnID)
column, rather than the index? This is a dynamically built datagrid, and
when I refer to dg.Column(0), it works fine, but if I refer to
dg.Column("ID"), I get an error saying the string format is incorrect. But
I don't always know what the column number is so I have to refer to it by
name:
With dg
.AutoGenerateColumns = "False"
.CellPadding="4"
.BackColor=Color.White
.BorderWidth = Unit.Pixel(3)
.GridLines=GridLines.Horizontal
.BorderStyle=BorderStyle.Double
.ShowHeader = true
.HeaderStyle.BackColor = Color.Black
.HeaderStyle.ForeColor = Color.White
.HeaderStyle.Font.Bold = true
.EditItemStyle.BackColor = Color.Silver
End With
Dim DGBoundColumnID as New BoundColumn
With DGBoundColumnID
.Visible=False
.DataField="ID"
.ReadOnly=True
End With
dg.Columns.Add(DGBoundColumnID)