Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I was created a html dropdown list for job recruitment
XML
<option value="select">-------------------------------Select----------------------------------</option>
<option value="1" id="koi">Accounts / Finance / Tax / CS / Audit</option>
<option value="46">Agent</option>
<option value="81">Analytics &amp; Business Intelligence</option>


am select agent option in dropdown list and submited the entire details to sql server 2008 using sqlparameter method..after submit i was checked my datbase i can see that the agent option value"46" saved in the database.. Only I wanted to save option into the database dont wanted to save option value.
Posted
Comments
Gitanjali Singh 20-Jan-14 1:26am    
Please share your code for saving data to database.
[no name] 20-Jan-14 4:20am    
protected void act(object sender, EventArgs e)
{

try
{



Connection = ConfigurationManager.AppSettings["mycon"];
SqlParameter[] reg_para = new SqlParameter[3];
string sss = Drd_job_category.Items[Drd_job_category.SelectedIndex].Text.ToString();
reg_para[0] = new SqlParameter("@intmode", 1);
reg_para[1] = new SqlParameter("@fullname", txt_Fullname.Value.Trim());
reg_para[2] = new SqlParameter("@email", Txt_Email.Value.Trim());
int i = SqlHelper.ExecuteNonQuery(Connection, CommandType.StoredProcedure, "[jobconsultency]", reg_para);



if (i>0)
{

completed.Text = "Succsusfully Registered";

cleartext();

}
else
{

completed.Text = "sorry...Try Again";
}
}
catch (Exception ex)
{

completed.Text = "Sorry..... Server error. refresh your page !";
}
}
Christian Graus 20-Jan-14 4:23am    
It would be better if you edited your post so this would be more readable, but you'll notice, both the other answers you got were correct, but we couldn't give you the exact text because we did not have the code.
[no name] 20-Jan-14 4:15am    
I can't get you? what u need ? sql inserting code

try
C#
string text =  DropDownList1.Text;
                       //(Or)
          string value = DropDownList1.SelectedItem.Text;
 
Share this answer
 
string sss = Drd_job_category.Items[Drd_job_category.SelectedIndex].Text.ToString();
 
Share this answer
 
Comments
Christian Graus 20-Jan-14 4:23am    
Why call ToString, when you're already accessing the Text property ?
What Karthik is saying is that you've stored the value, because you stored the value. The Text property is what you need, not the value property. You should show the code that has the issue, in future, the code you posted is working, unless you want to show 46 in your list and store the string, this is not what has to change. you should also learn to use your debugger so you can see what your code is doing and fix it from there. Of course, Karthik did not give you a copy and paste solution, again because you did not give us the actual code that has the issue, only some code that's somewhat related, but really irrelevant to your issue.
 
Share this answer
 

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