Click here to Skip to main content
15,910,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I have this code for passing listbox items text to textbox but I get System.data.DataRowView instead of the text of those text of items\

C#
foreach (var item in listPattern1.Items)
            {
                txtPattern.Text += "," + item.ToString() + ",";
            }



I dont know how to get text of those items
Posted

This is simple solution what ever selected in listbox you want to show it in a textbox the code is

C#
string selectedvalues=string.Empty;
foreach(ListItem li in lstbox.Items)
if(li.Selected)
  selectedvalues+=li.Text+", ";

txtSelected.Text=selectedvalues(0,selectedvalues.LastIndexOf(","));


Simple :)
 
Share this answer
 
Comments
shonezi 5-Nov-12 5:11am    
it says on ListItem that I am missing a directive or assembly reference????
Because I am stupid, and stupid and I am sorry for asking that I already got solved here some time ago, but I had little differences, and I am truly sorry for asking the same thing

very stupid of me, thanks anyway everybody
 
Share this answer
 
Comments
Nelek 6-Nov-12 15:27pm    
Have you tried to search your old question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900