【发布时间】:2014-02-15 02:28:50
【问题描述】:
我有一个类似下面的 Json: [{“示例温度”:“值”},{“示例默认”:“”,“选定”:真}]
我需要填写一个下拉列表,例如: 下拉列表应包含值:示例 temp 默认示例
Example Default 应该是默认选择的值,
我试过下面的代码:
JArray jArray = JArray.Parse(jsonstring);
foreach (JObject jObject in jArray.Children<JObject>())
{
foreach (JProperty jProperty in jObject.Properties())
{
string name = jProperty.Name.Trim();
string value = jProperty.Value.ToString().Trim();
drpValues.Items.Add(new RadComboBoxItem(name, value));
}
}
但“选定”也以下拉值的形式出现。
非常感谢任何帮助。
非常感谢!
-PT
【问题讨论】:
-
你能改变你的json格式吗?如果您可以将其更改为
[{"Text" : "Example temp", "Value" : "SomeValue"}, {"Text" : "Example Default", "Value" : "", "selected": true}]之类的内容会更容易 -
感谢您的回复 ekad!如何用这个 json 填充下拉列表,请帮忙!我将此 json 与我的下拉填充逻辑一起使用,现在我将下拉值作为示例 temp、Value、Text、Value