Hello,
I am trying to pass combobox value to a database, using a 3 tier business logic. Currently my form page looks like this:
privatevoidSavebtn_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());}}publicvoidSaveRole(stringRoleDesc,/*combobox selecteditem*/){ClubRoles cr =newClubRoles();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:
privatevoid loadclient(){DataSet dsloadclient; dsloadclient =newClubRoles().createdby();//need fix duplicate valuesDataTable dt = dsloadclient.Tables[0].DefaultView.ToTable(true,"ClientName","ClientId"); lstcreatedby.DataSource= dt; lstcreatedby.DisplayMember="ClientName"; lstcreatedby.ValueMember="ClientId";}
Any help will be appreciated.
Thanks.