Turning a Datagrid DataItem into an array.
Posted on 2004-09-24
I have used this method to create an array of items from a datagrid row:
Dim dg As DataGrid = CType(Page.FindControl("dgCharges"), DataGrid)
Dim rowView As DataRowView = CType(dg.SelectedItem.DataItem, DataRowView)
If Not rowView Is Nothing Then
Dim itemArray As Array = rowView.Row.ItemArray
When running the code, the datagrid and it's selectedItem are found
but the DataItem is Nothing. Why is this?
If this won't work, how can I create an array of the cells from the DataGridItem?