Youre on the right path.
Private Sub cmbStores_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cmbStores.SelectedIndexChanged
'try this
dim o as object
o = cmbStores.SelectedItem
if not (o is nothing) then
Console.Write ( o.GetType().ToString() )
'put a watch on "o" in the debugging window, and it should tell you
the type also
end if
' drvStores = DirectCast(cmbStores.SelectedItem, DataRowView)
' MsgBox(drvStores("Address"))
End Sub
the dim o as object is ONLY FOR FIGURING OUT WHAT YOU GOT.
DO NOT LEAVE THAT IN THERE.
after you have the object type, then you can cast.
PS
You might want to bind your combobox to the dataset.TABLE , not just hte
dataset.
Ex:
if not ( ds.Tables(0) is nothing) then
cbo1.DataSource = ds.Tables(0)
end if
OR better (if its a strong typed dataset)
if not ( ds.Employee is nothing) then
cbo1.DataSource = ds.Employee
end if
where Employee is a strong table name in your dataset.
"Hetal" <he*************@gmail.comwrote in message
news:11**********************@t38g2000prd.googlegr oups.com...
Thank you sloan. I created an object of class DataRowView and i am
casting the item selected in Combo Box to DataRowView. Keeping the
previous example in mind, here is the snippet of code that i wrote to
get the Address from DataSet.
'In Declaration section.
Dim drvStores As DataRowView
'Code to read the data from dataset based on combo item selection.
Private Sub cmbStores_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cmbStores.SelectedIndexChanged
drvStores = DirectCast(cmbStores.SelectedItem, DataRowView)
MsgBox(drvStores("Address"))
End Sub
Am i heading the right direction? I mean, is this an efficient way of
reading data from a dataset? Thanks.