我想将下拉选项保存到sql server table 2008中 [英] I wanted to save dropdown option into sql server table 2008

查看:52
本文介绍了我想将下拉选项保存到sql server table 2008中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个html下拉列表,用于招聘

I was created a html dropdown list for job recruitment

<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>





下拉列表中的select agent选项,并使用sqlparameter将整个详细信息提交给sql server 2008方法..提交后我检查了我的数据库我可以看到代理选项值46保存在数据库中..只是我想将选项保存到数据库中而不想保存选项值。



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.

推荐答案

尝试

try
string text =  DropDownList1.Text;
                       //(Or)
          string value = DropDownList1.SelectedItem.Text;


string sss = Drd_job_category .Items [Drd_job_category.SelectedIndex] .Text.ToString();
string sss = Drd_job_category.Items[Drd_job_category.SelectedIndex].Text.ToString();


Karthik所说的是你存储了值,因为你存储了值。 Text属性是您需要的,而不是value属性。您应该显示出问题的代码,将来,您发布的代码正在运行,除非您想在列表中显示46并存储字符串,这不是必须更改的内容。您还应学会使用调试器,以便查看代码正在执行的操作并从中进行修复。当然,Karthik没有给你一个复制和粘贴解决方案,因为你没有给我们提供有问题的实际代码,只有一些代码有点相关,但与你的问题无关。
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.

这篇关于我想将下拉选项保存到sql server table 2008中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆