复制DropDownListItems不用循环 [英] Duplicating DropDownListItems Without Looping

查看:137
本文介绍了复制DropDownListItems不用循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就像一个魅力...加载DropDownList2从DropDownList1所有物品不用循环:

This works like a charm... loading DropDownList2 with all the items from DropDownList1 without looping:

DropDownList2.DataSource = DropDownList1.Items;
DropDownList2.DataBind();

不过,从DropDownList1的项目文本的数据被复制到两个DropDownList2的文本和值字段。反正是有得到文本和值字段填入正确?

But, the data from the item text of DropDownList1 is copied into both the text and value fields of DropDownList2. Is there anyway to get both the text and the value fields to populate properly?

推荐答案

请问这项工作?

DropDownList2.DataSource = DropDownList1.Items;
DropDownList2.DataTextField = "Text";
DropDownList2.DataValueField = "Value";
DropDownList2.DataBind();

这篇关于复制DropDownListItems不用循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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