combobox Problem....
-
I am working in window based application funFillCombo_prod(CmbProduct, "select productid,product from product_master where status=1") CmbProduct.ValueMember = "productid" CmbProduct.DisplayMember = "product" CmbProduct.SelectedIndex = 0 In function I fill the combobox ……… by dataset Public Function funFillCombo_prod(ByVal cmbCombo As ComboBox, ByVal strsql As String) As Boolean Try Dim intI As Integer If con.State <> ConnectionState.Open Then con.Open() GDataAdapter = New SqlDataAdapter(strsql, con) GDataSet = New DataSet() GDataAdapter.Fill(GDataTable) cmbCombo.DataSource = GDataTable.DefaultView funFillCombo_prod = True Catch ex As Exception MsgBox(Err.Source & " : " & Err.Description, vbInformation, g_MSG_Title) funFillCombo_prod = False Finally GDataSet = Nothing End Try Exit Function End Function Private Sub CmbProduct_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbProduct.SelectedIndexChanged If CmbProduct.Items.Count > 0 Then If CmbProduct.SelectedIndex <> -1 Then MessageBox.Show(CmbProduct.SelectedValue.ToString()) End If End If End Sub Problem is that in CmbProduct_SelectedIndexChanged I want valumember of a combobox But msgbox which I write in that event is giving me the desired o/p but problem is that… For two times I got this message System.Data.DatarowView. then I got the valuemember which I require, Please tell me how to solve this System.Data.DatarowView. Problem
-
I am working in window based application funFillCombo_prod(CmbProduct, "select productid,product from product_master where status=1") CmbProduct.ValueMember = "productid" CmbProduct.DisplayMember = "product" CmbProduct.SelectedIndex = 0 In function I fill the combobox ……… by dataset Public Function funFillCombo_prod(ByVal cmbCombo As ComboBox, ByVal strsql As String) As Boolean Try Dim intI As Integer If con.State <> ConnectionState.Open Then con.Open() GDataAdapter = New SqlDataAdapter(strsql, con) GDataSet = New DataSet() GDataAdapter.Fill(GDataTable) cmbCombo.DataSource = GDataTable.DefaultView funFillCombo_prod = True Catch ex As Exception MsgBox(Err.Source & " : " & Err.Description, vbInformation, g_MSG_Title) funFillCombo_prod = False Finally GDataSet = Nothing End Try Exit Function End Function Private Sub CmbProduct_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbProduct.SelectedIndexChanged If CmbProduct.Items.Count > 0 Then If CmbProduct.SelectedIndex <> -1 Then MessageBox.Show(CmbProduct.SelectedValue.ToString()) End If End If End Sub Problem is that in CmbProduct_SelectedIndexChanged I want valumember of a combobox But msgbox which I write in that event is giving me the desired o/p but problem is that… For two times I got this message System.Data.DatarowView. then I got the valuemember which I require, Please tell me how to solve this System.Data.DatarowView. Problem
soniasan wrote:
Please tell me how to solve this System.Data.DatarowView. Problem
This means you have not set the ValueMember of the combobox, so it's showing the ToString of the object referred to
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I am working in window based application funFillCombo_prod(CmbProduct, "select productid,product from product_master where status=1") CmbProduct.ValueMember = "productid" CmbProduct.DisplayMember = "product" CmbProduct.SelectedIndex = 0 In function I fill the combobox ……… by dataset Public Function funFillCombo_prod(ByVal cmbCombo As ComboBox, ByVal strsql As String) As Boolean Try Dim intI As Integer If con.State <> ConnectionState.Open Then con.Open() GDataAdapter = New SqlDataAdapter(strsql, con) GDataSet = New DataSet() GDataAdapter.Fill(GDataTable) cmbCombo.DataSource = GDataTable.DefaultView funFillCombo_prod = True Catch ex As Exception MsgBox(Err.Source & " : " & Err.Description, vbInformation, g_MSG_Title) funFillCombo_prod = False Finally GDataSet = Nothing End Try Exit Function End Function Private Sub CmbProduct_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbProduct.SelectedIndexChanged If CmbProduct.Items.Count > 0 Then If CmbProduct.SelectedIndex <> -1 Then MessageBox.Show(CmbProduct.SelectedValue.ToString()) End If End If End Sub Problem is that in CmbProduct_SelectedIndexChanged I want valumember of a combobox But msgbox which I write in that event is giving me the desired o/p but problem is that… For two times I got this message System.Data.DatarowView. then I got the valuemember which I require, Please tell me how to solve this System.Data.DatarowView. Problem