populating combo box on selectedindex changedevent of other combo box1
-
Hello EveryBody, I had two combo box (combo box1, combo box2) I had populated the combox1 using dataset (having values in display member and value member) I want to pupulate combo box2 on the selectedindexChangeEvent but I am getting System.Data.DataRowView on comboBox1.selectedvalue.tostring(); I am unable to understand why it is returning this value. And outside this event it is giving right value. working on c# (windows application) Regards, rahul saini
-
Hello EveryBody, I had two combo box (combo box1, combo box2) I had populated the combox1 using dataset (having values in display member and value member) I want to pupulate combo box2 on the selectedindexChangeEvent but I am getting System.Data.DataRowView on comboBox1.selectedvalue.tostring(); I am unable to understand why it is returning this value. And outside this event it is giving right value. working on c# (windows application) Regards, rahul saini
It would be more helpful if you could put some code also...
Just call me Valy... :)
-
It would be more helpful if you could put some code also...
Just call me Valy... :)
Hi Valy, Here is the code for populating the combo box1 string sqlQuery = "select * from category "; SqlConnection objConnection = new SqlConnection(objFunctions.strConn); objConnection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sqlQuery, objConnection); DataSet ds = new DataSet(); adapter.Fill(ds); DataTable objDataTable = ds.Tables[0]; cmb_category.DataSource = objDataTable; cmb_category.DisplayMember = "categoryName"; cmb_category.ValueMember = "categoryId"; objConnection.Close(); AND on selectedIndexChangeEvent I m populating combo box using comboBox1.selectedValue but it is returning System.Data.DataRowView Regards, rahul saini
-
Hi Valy, Here is the code for populating the combo box1 string sqlQuery = "select * from category "; SqlConnection objConnection = new SqlConnection(objFunctions.strConn); objConnection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sqlQuery, objConnection); DataSet ds = new DataSet(); adapter.Fill(ds); DataTable objDataTable = ds.Tables[0]; cmb_category.DataSource = objDataTable; cmb_category.DisplayMember = "categoryName"; cmb_category.ValueMember = "categoryId"; objConnection.Close(); AND on selectedIndexChangeEvent I m populating combo box using comboBox1.selectedValue but it is returning System.Data.DataRowView Regards, rahul saini
hi instead of using combobox1.selectedvalue you have to use combobox1.selectedindex.tostring() Nisar Inamdar.
-
hi instead of using combobox1.selectedvalue you have to use combobox1.selectedindex.tostring() Nisar Inamdar.
-
Hi Nisar, It is giving the index value but i want the selectedItemValue for populating comboBox2 with help of the value i had to retrieve value from database Regards, rahul saini
Hi Rahul, on combo1.selectedIndexEvent use query " Select fieldName from tablname where fieldname="+combo1.Selectedindex.toString()"; Nisar Inamdar.
-
Hi Valy, Here is the code for populating the combo box1 string sqlQuery = "select * from category "; SqlConnection objConnection = new SqlConnection(objFunctions.strConn); objConnection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sqlQuery, objConnection); DataSet ds = new DataSet(); adapter.Fill(ds); DataTable objDataTable = ds.Tables[0]; cmb_category.DataSource = objDataTable; cmb_category.DisplayMember = "categoryName"; cmb_category.ValueMember = "categoryId"; objConnection.Close(); AND on selectedIndexChangeEvent I m populating combo box using comboBox1.selectedValue but it is returning System.Data.DataRowView Regards, rahul saini
I think I got it. You must use ((DataRowView)comboBox1.SelectedItem).Row["categoryId"].ToString() instead of comboBox1.selectedValue
Just call me Valy... :)
-
Hi Rahul, on combo1.selectedIndexEvent use query " Select fieldName from tablname where fieldname="+combo1.Selectedindex.toString()"; Nisar Inamdar.
Yes I using the same query but as on populating comboBox1 i get category1 its value is 23 category2 its value is 32 but when on selecting category1 its index value is 0 and that is wat comboBox1.selectIndex is giving and i want its value that is 23. Regards, rahul saini
-
I think I got it. You must use ((DataRowView)comboBox1.SelectedItem).Row["categoryId"].ToString() instead of comboBox1.selectedValue
Just call me Valy... :)
-
Yes I using the same query but as on populating comboBox1 i get category1 its value is 23 category2 its value is 32 but when on selecting category1 its index value is 0 and that is wat comboBox1.selectIndex is giving and i want its value that is 23. Regards, rahul saini
;)hi rahul, Try combo1.SelectedItem.ToString(); It will be worked. Nisar Inamdar.