Click here to Skip to main content
14,879,482 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i had dropdown list in my page if i selected the selected vaue dosen't inserting into the DB it defaultly takes the first value in the dropdown list.


can any one help me to solve this probs
Posted
Comments
[no name] 6-Jul-13 8:18am
   
You seriously expect us to tell you what is wrong with your code without seeing it?
Adarsh chauhan 8-Jul-13 4:17am
   
Please share your code, only then we can tell you where you are going wrong.
Without seeing your code we can only make guesses..

i think you expect this one...

C#
<asp:dropdownlist id="ddlCountry" runat="server" cssclass="textboxStyle1"
   AppendDataBoundItems="True"  >
 <asp:listitem value="-1">-- Select --</asp:listitem>
  </asp:dropdownlist>
   
v4
Bind the dropdownlist inside
if(!IsPostBack)
{
// Bind your Dropdownlist Here
}
   
XML
<asp:dropdownlist id="ddlCountry" runat="server" >
   <asp:listitem value="-1">Your Item</asp:listitem>
     
   //add line items here
     </asp:dropdownlist>


But you have to know which you are going to insert, Value or item.

and in db you have to specify the datatype for that column whether int (for value) and nvarchar (for item)

SQL
DropDownList1.SelectedItem;     //it will insert the selected text
    DropDownList2.SelectedValue
//it will insert value


Still if you need more clarification paste your code here.
   

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