Why Can't I store XML in ASP.NET ListBox Value?
Posted
by mcass20
on Stack Overflow
See other posts from Stack Overflow
or by mcass20
Published on 2010-06-08T14:59:25Z
Indexed on
2010/06/08
15:02 UTC
Read the original article
Hit count: 229
Hello,
Why does this work:
ListItem item = new ListItem();
string value = lstAvailExtPropsToFilter.SelectedItem.Text +" = "+ txtExtPropToFilter.Text;
string text = lstAvailExtPropsToFilter.SelectedItem.Text + " = " + txtExtPropToFilter.Text;
item.Text = text;
item.Value = value;
lstExtPropsToFilter.Items.Add(item);
But not this:
ListItem item = new ListItem();
string value = string.Format("<key>{0}</key><value>{1}</value>", lstAvailExtPropsToFilter.SelectedItem.Text, txtExtPropToFilter.Text);
string text = lstAvailExtPropsToFilter.SelectedItem.Text + " = " + txtExtPropToFilter.Text;
item.Text = text;
item.Value = value;
lstExtPropsToFilter.Items.Add(item);
© Stack Overflow or respective owner