Click here to Skip to main content
15,918,343 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to bind list box item into text box in webform without using button click event??
Posted
Updated 1-Dec-11 18:34pm
v3
Comments
Sergey Alexandrovich Kryukov 1-Dec-11 2:35am    
Using what library? Tag it!
--SA
Michel [mjbohn] 1-Dec-11 2:37am    
added tag

You could try this:

C#
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
  if ((sender as ListView).SelectedItems.Count>0)
  {
    textBox2.Text = (sender as ListView).SelectedItems[0].Text;
  }
}
 
Share this answer
 
Comments
Mukunda Raj 1-Dec-11 2:21am    
After adding your code in the list box selected index,i`m getting error...

Error 14 'System.Web.UI.WebControls.ListView' does not contain a definition for 'SelectedItems' and no extension method 'SelectedItems' accepting a first argument of type 'System.Web.UI.WebControls.ListView' could be found (are you missing a using directive or an assembly reference?)
Michel [mjbohn] 1-Dec-11 2:34am    
Well you should have mentioned that your on ASP and not on WinForms.
Sorry I have no solution for WebControls.ListView
lukeer 1-Dec-11 2:36am    
That is why you should always tag your question with the technology you're using. mjbohn posted a perfectly working solution for Windows Forms.
Since your error message points to the namespace "System.Web.UI", it is unlikely that you use Forms.

Improve your question and tell us if you use ASP.NET or something else.
Sergey Alexandrovich Kryukov 1-Dec-11 2:36am    
Please see my comment. This is because you did not tag important classifier information. How could you hope for correct answer?
--SA
 
Share this answer
 
v2

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