ASP.NET下拉菜单和文本框错误保存数据库 [英] Asp.net dropdown and textbox error saving database

查看:73
本文介绍了ASP.NET下拉菜单和文本框错误保存数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,程序员,这里遇到了一个大问题.大家都看到的是,我只想保存数据库中的数据,无论现有数据是否进入下拉菜单,新数据是否进入文本框.现在,我已经使用SQL语句NOT IN在下拉列表中绑定数据,到目前为止,它仍然有效.我通过使用if else语句来限制输入,就是这样:
代码

hello programmers, got a huge problem here. As you all see all i want is to save data from database whether existing goes to dropdown and if new goes to textbox. now Ive manage to bind data on dropdown using the SQL statement NOT IN and so far it works. I limit inputing by using if else statement so this is it:
Code

If txtcategory.Text <> "" And drpdwnExistingCat.SelectedValue = "" Then
txtcategory saved.. on my databases
ElseIf txtcategory.Text <> "" And drpdwnExistingCat.SelectedValue <> "" Then
 If txtcategory.Text = drpdwnExistingCat.SelectedItem.Text Then
 msgbox("error")not really my code
 else
 Saved both


现在正在研究是否要其他


Now in is working say on if else

txtcategory.text = "Trying"
drpdwnExistingCat.SelectedItem.Text = "Trying"


但是当我更改字母大小写时,说


But when I change the letter case say

txtcategory.text = "TRYING"
drpdwnExistingCat.SelectedItem.Text = "Trying"


两者都保存,所以我得到了一个错误.我该如何解决这种错误.请帮忙.

谢谢,还有更多功能.


Both save so ive got an error. How can I fix this kind of error. Please help.

Thanks and more power.

推荐答案

好吧,您可以将两个值都转换为大写字母,然后将大小写字母进行比较.

为此,您可以使用ToUpper()方法.为此,请检查 MSDN [ ^ ]

但是当我检查您的代码时,似乎您正在将文本框值与组合框"x selectedvalue"进行比较?您只想将文本框值与组合框的selectedValue或此组合框中的所有项目进行比较?

祝你好运
Well you can get both values to uppercase letters and then compare them if thats the case.

To do it you can use ToUpper() method it. For it check here on MSDN[^]

But when I check your code it seems like you are comparing the textbox value with the combobox''x selectedvalue? you only want to compare the textbox value with the combobox''s selectedvalue or all the items in this combobox?

Good luck


这篇关于ASP.NET下拉菜单和文本框错误保存数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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