Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

error while using combo box

$
0
0

con.Open();
            cmd.Connection = con;
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter("Select Class_ID,Class_Name from tbl_Class where Delete_Status='False'", con);
            da.Fill(ds);
            DataRow dr = ds.Tables[0].NewRow();
            dr[1] = "--Select--";
            ds.Tables[0].Rows.InsertAt(dr, 0);
            Cmb_Class.DataSource = ds.Tables[0];
            Cmb_Class.ValueMember = "Class_ID";
            Cmb_Class.DisplayMember = "Class_Name";
            con.Close();
            Cmb_Class.SelectedValue = Dgv_Section.CurrentRow.Cells[1].Value.ToString();

this is d code i m using, to fill d combobox and then selecting d value from filled combobox, 
d error is at Cmb_Class.SelectedValue, its giving error "Input string was not in correct format" but d value in Dgv_Section.CurrentRow.Cells[1].Value.ToString(); is string which is correct what i expect to come

anybody can help plssssss


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>