Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
Hi,
Please can anyone help

there is 1 dropdown list 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 save in the database with the column name "Inserted".
Posted
Comments
PrashantSonewane 15-Apr-13 4:33am    
Where did you stuck? Can you give problem details? you can put your code as well.
babli3 15-Apr-13 4:44am    
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("@TierCode", Convert.ToInt32(userbranchgrplistbox.Text));
cmd.Parameters.AddWithValue("@BranchCode", Convert.ToInt32(branchddl.SelectedValue));
cmd.CommandType = CommandType.StoredProcedure;
myconnection.Open();
cmd.Connection = myconnection;
cmd.ExecuteNonQuery();
myconnection.Close();

}
babli3 15-Apr-13 5:49am    
1.when i select a value in the dropdownlist , it should show in a list box.(This i have done)
2. These data(multiple values ) from list box should get stored into the database(here i am having trouble).

Please can someone help!!

1 solution

var ddl = this.DropDownList1.Items.Cast>();
var lst = this.lstid.Items.Cast>();
if (ddl.ToArray().Intersect(lst.ToArray()).Count() == ddl.Count())
{
//insert to database
}
else
{
//Please check duplicate intem isnsertion
//insert to listBox
}
 
Share this answer
 
Comments
babli3 15-Apr-13 4:49am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900