Issue getting value from dynamically creating datagrid boundcolumn

E

Erik

Good Afternoon,
I am dynamically creating boundcolumns for a datagrid during the databinding
event. Everything is rendered properly, but I am unable to get the value of
the boundcolumn. The count for the datagridrow cells is only returning 1,
which is the static templatecolumn.
Any suggestions / insights on why I can't retrieve the values of the
boundcolumns is greatly appreciated.
Below is the code building the boundcolumns.
Thanks, Erik

Private Sub dgrdEquip_DataBinding(ByVal sender As Object, ByVal e As
System.EventArgs) Handles dgrdEquip.DataBinding
'During the databinding we will loop through the columns on the
datatable
'and build a tempalte column that has one imagebutton in it
'add it to the grid.columns collection then
'create another boundcolumn that would display the value in the column

Dim tbl As DataTable = dstEquipInv.Tables("EquipInv")
If tbl.Rows.Count <> 0 Then
Dim dc As DataColumn

For Each dc In tbl.Columns

Dim bc As New BoundColumn 'add a column to contain the
value of the field
bc.DataField = dc.ColumnName
bc.HeaderText = dc.ColumnName
bc.HeaderStyle.CssClass = "TDHeader"
bc.SortExpression = dc.ColumnName

bc.ItemStyle.CssClass = "TDItem"

CType(sender, DataGrid).Columns.Add(bc)
End If
Next
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top