如何解决这个问题 [英] How can solve this Issue

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

问题描述

大家好,

我将值存储在xml文件中。并取出组合框。



这里我通过了combobox选择的值。这里添加符号所以结果没有来我怎么解决这个。



我的xml代码是

hi all,
I am storing values in xml file. and fetching to combobox.

here I am passing combobox selected value. here adding symbol so result not came how can I solve this.

my xml code is

<?xml version="1.0" encoding="utf-8"?>
<Items>
  <Item>
    <ItemText>1/2"</ItemText>
    <ItemValue>0.5</ItemValue>
  </Item>
 </Items>







var users = from person in xmlDoc.Descendants("Items").Elements("Items")
                                where person.Element("ItemText").Value == cmbRodDiameter.SelectedItem.ToString()
                                select new
                                {
                                    ItemValue = person.Element("ItemValue").Value,
                                };

                    foreach (var items in users)
                    {
                        txtRodDValue.Text = items.ItemValue;
                    }
//here combobox value is passing 1/2"\" 
//insted of 1/2" that''s y not came the result so how can I do.

推荐答案

假设您将数据绑定到组合框正确ly,

然后代替使用:

Assuming you are binding your data to the combo box correctly,
then instead of using:
cmbRodDiameter.SelectedItem.ToString()



使用


Use

cmbRodDiameter.SelectedValue.ToString()


似乎拼写错误!!



替换

Seems spelling mistake!!

Replace
xmlDoc.Descendants("Items").Elements("Items")



with


with

xmlDoc.Descendants("Items").Elements("Item")





:)



:)


这篇关于如何解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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