如何从sql到dropdownlist获取带空格的字符串 [英] how to get string with spaces from sql to dropdownlist

查看:75
本文介绍了如何从sql到dropdownlist获取带空格的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sql数据库中有一个值为Additional Work的字段。但是我无法将值检索到下拉列表。没有空间,它正在接受。如何用空格接受值.....

i have a field with value "Additional Work" in sql database. But im not able to retrieve the value to dropdownlist. Without spaces it''s accepting. how to accept the value with spaces.....

推荐答案

如果你想通过分隔空格来添加元素,那么你可以使用String.split函数并通过分隔你可以通过空格将它们添加到下拉列表中
If you want to add elements by seprating with spaces then you can use String.split function and by seprating them by spaces you caan add them to dropdownlist


txtclass.SelectedValue = (objDataSet.Tables[0].Rows[0]["Class"]).ToString();

,假设txtclass实际上是一个下拉列表。你能检查一下列表的开头或结尾是否有流氓空格?值应为< asp:ListItem> Anglo Indian< / asp:ListItem> ;.

您尝试选择.SelectedValue ='的任何项目必须已经在列表中且必须是标签之间字符串的完全匹配

, assuming that txtclass is actually a dropdownlist. Can you check that there are no rogue white spaces at the beginning or end of the list? The values should read <asp:ListItem>Anglo Indian</asp:ListItem>.
Any item you try to select with ''.SelectedValue = '' must already be in the list and must be an exact match of the string between the tags


这篇关于如何从sql到dropdownlist获取带空格的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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