JeffDrummond
asked on
Turning a Datagrid DataItem into an array.
I have used this method to create an array of items from a datagrid row:
Dim dg As DataGrid = CType(Page.FindControl("dg Charges"), DataGrid)
Dim rowView As DataRowView = CType(dg.SelectedItem.Data Item, 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?
Thanks.
Dim dg As DataGrid = CType(Page.FindControl("dg
Dim rowView As DataRowView = CType(dg.SelectedItem.Data
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?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The ArrayList works well for my purposes. Thanks!
ASKER
And you may be right too about the DataItem only being available during databinding.
That's the only other time I've used it.
That's the only other time I've used it.
Dim keyID As Integer = CType( MyDataGrid.DataKeys(dg.Sel
myDataTable.Rows.Find( 'use key to find row
As to why dg.SelectedItem.DataItem is null, I vaguely remember something about it only being available during binding, but I have about 10% certainty on that memory, so don't take my word for it.