Hi,
Please can anyone help me in doing this
There is 1 dropdownlist and 1 listbox and 1 insert button.
dropdownlist will contain all the choices and if user choose one and hit the insert button it will be inserted in the listbox, and if user would like to insert another item it will be inserted again in the listbox.
and then lets say that the listbox now contain all of the items chosen by the user.
if save button was clicked it will all be saved into the database with the column name "Inserted".
I managed to finish the first part which is selecting items from dropdownlist into the list box.
But, I am having trouble in saving the data from list box(multiple data) to the database.
Please can someone help me....
protected void usersavebtn_Click(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.AppSettings["ApplicationServices"];
SqlConnection myconnection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("sp_InsertAdmin_User", myconnection);
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@Userid", Convert.ToInt32(usersddl.SelectedValue));
cmd.Parameters.AddWithValue("@Tier", userbranchgrplistbox.SelectedValue);
cmd.Parameters.AddWithValue("@Branch", userbranchlistbox.SelectedValue);
cmd.CommandType = CommandType.StoredProcedure;
myconnection.Open();
cmd.Connection = myconnection;
cmd.ExecuteNonQuery();
myconnection.Close();
}
above is the code i have tried...
Tier dropdown is text but i have to store its id in the database..