Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
string constr = @"Data Source=192.168.*.*; Database=wsditsupport; User ID=**; Password=**";
       public Form7()
       {
           InitializeComponent();

           MySqlConnection cn = new MySqlConnection(constr);
           string value = "SELECT passover_info FROM probing_production";
           MySqlDataAdapter adp = new MySqlDataAdapter(value, cn);
           DataTable dt = new DataTable();
           adp.Fill(dt);
           comboBox1.DataSource = dt;
           comboBox1.DisplayMember = "passover_info";
           cn.Close();
       }

       private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
       {
           if (comboBox1.SelectedIndex == -1)
           {
               textBox1.Text = string.Empty;
           }
           else
           {
               textBox1.Text = comboBox1.SelectedItem.ToString();
           }
       }
   }


What I have tried:

When I try run debug, This is the result I get into textbox >>> "System.Data.DataRowView"
Posted
Updated 22-Jun-16 20:50pm
v2

1 solution

try this

C#
else
           {
               textBox1.Text = ((DataRowView)comboBox1.SelectedItem)["passover_info"].ToString();
           }
 
Share this answer
 
Comments
Nigol_Learner 23-Jun-16 3:24am    
Bro, you are super, thank you very much bro.
Karthik_Mahalingam 23-Jun-16 4:00am    
Cool,
if your issue is resolved, please close this post

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900