Hello,
I am trying to pass combobox value to a database, using a 3 tier business logic. Currently my form page looks like this:
private void Savebtn_Click(object sender, EventArgs e) { try { SaveRole(tbroledesc.Text, /*combobox selected item gets passed here*/); MessageBox.Show("Club role saved successfully"); } catch (Exception er) { MessageBox.Show(er.Message.ToString()); } } public void SaveRole(string RoleDesc, /*combobox selecteditem*/) { ClubRoles cr = new ClubRoles(); RoleCreatedBy = Convert.ToInt32(lstcreatedby.SelectedItem); cr.insertingclubroles(RoleDesc, RoleCreatedBy); gettingclubroles(); //refresh the list }
How can I pass what ever is selected in the combobox drop down as the parameter?
I am filling the combobox like this:
private void loadclient() { DataSet dsloadclient; dsloadclient = new ClubRoles().createdby(); //need fix duplicate values DataTable dt = dsloadclient.Tables[0].DefaultView.ToTable(true, "ClientName", "ClientId"); lstcreatedby.DataSource = dt; lstcreatedby.DisplayMember = "ClientName"; lstcreatedby.ValueMember = "ClientId"; }
Any help will be appreciated.
Thanks.