Click here to Skip to main content
15,916,463 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hI,

I have following dropdown

<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>Please Select
<asp:ListItem>A
<asp:ListItem>B
<asp:ListItem>C
<asp:ListItem>D


I want to save the value like when i select a or b or c or d any one of the value if i select and on click of the save button the any of these value get saved into sql server , pls guide me how can i do so
Posted
Updated 4-Feb-13 17:25pm
v5
Comments
Naveen.Sanagasetti 4-Feb-13 23:22pm    
please elaborate your question..

you select one dropdown item, that item value you need to save in SQL table , right ...?

for this first of all you create SQL table, and in page wise you select the item whatever you want based upon the item you fetch selected value, then that value you save in your DB.
 
Share this answer
 
SqlConnection cn = new SqlConnection(cnstr);
SqlCommand cmd = new SqlCommand("insert into Employe values('" + DropDownList1.SelectedValue + "')", cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();

May be this help you try it once.....other wise in the place of "selected item" once you can try "selected value".
 
Share this answer
 
Comments
Software Engineer 892 18-Sep-13 4:31am    
Thanks, its works fine for me.

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