多个文本到下拉列表 [英] multiple text to dropdownlist

查看:58
本文介绍了多个文本到下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的字符串..
asdfg,ahahaha,ajajajaja

我想在下拉列表中插入文字

i have string like this ..
asdfg,ahahaha,ajajajaja

i want to insert text to dropdownlist
can some one halp me?

推荐答案

尝试:
string s = "asdfg,ahahaha,ajajajaja";
myDropDownList.Items.AddRange(s.Split(','));


如果您希望将csv值作为列表项插入,可以尝试以下代码示例.

您可以将ddlText替换为下拉列表的ID.

If you are looking to insert the csv values as list items you can try the below code sample.

You can replace ddlText with the ID of your dropdown list.

Dim strText As String = "asdfg,ahahaha,ajajajaja"

Dim strTextList As String() = strText.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)

'remove the list items from dropdown
ddlText.Items.Clear()

'Add an empty ListItem
ddlText.Items.Add(New ListItem("", ""))

For i As Integer = 0 To strTextList.Length - 1
    ddlText.Items.Add(New ListItem(strTextList(i), strTextList(i)))
Next


这篇关于多个文本到下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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