<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Need a little help - .NET - tribe.net</title>
    <link>http://dotnutz.tribe.net/thread/ef291caa-7aab-4604-b199-50e5b974aa0d?format=rss</link>
    <description>Tribe.net. Local Connections</description>
    <item>
      <title>Re: Need a little help</title>
      <link>http://dotnutz.tribe.net/thread/ef291caa-7aab-4604-b199-50e5b974aa0d#2081701c-0a1d-487e-85cb-fff3512c76fe</link>
      <description>also, i know i left it out because visual studio normally does this automatically, but i just remembered that sometimes i'll reopen a project that i haven't tried in a while, and the event bindings that were there will have disappeared, so i'd suggest making sure that your InitializeComponent method is getting called and you have something like this in there;&#xD;
this.lsbTest.SelectedIndexChanged += new System.EventHandler(this.lsbTest_SelectedIndexChanged);</description>
      <pubDate>Mon, 14 Nov 2005 19:38:28 GMT</pubDate>
      <guid isPermaLink="false">http://dotnutz.tribe.net/thread/ef291caa-7aab-4604-b199-50e5b974aa0d#2081701c-0a1d-487e-85cb-fff3512c76fe</guid>
      <dc:creator>ben</dc:creator>
      <dc:date>2005-11-14T19:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need a little help</title>
      <link>http://dotnutz.tribe.net/thread/ef291caa-7aab-4604-b199-50e5b974aa0d#3db5d340-4fc6-43cc-9aa2-6fde9a9ec7b4</link>
      <description>Firstly, i'd suggest wrapping the code you have in the Page_Load in a check for if(!Page.IsPostBack){}, that way you will only databind once.  Secondly, I tried this on a page and could not recreate.  This is all i have:&#xD;
&amp;amp;lt;asp:ListBox ID="lsbTest" Runat="server" AutoPostBack="True"&gt;&amp;amp;lt;/asp:ListBox&gt;&#xD;
&#xD;
private void Page_Load(object sender, System.EventArgs e)&#xD;
		{&#xD;
			if(!Page.IsPostBack)&#xD;
				for(int i=0;i&amp;amp;lt;5;i++)&#xD;
				{&#xD;
					ListItem item = new System.Web.UI.WebControls.ListItem("bob" + i.ToString(), i.ToString());&#xD;
					lsbTest.Items.Add(item);&#xD;
				}&#xD;
			// Put user code to initialize the page here&#xD;
		}&#xD;
&#xD;
		private void lsbTest_SelectedIndexChanged(object sender, System.EventArgs e)&#xD;
		{&#xD;
			Response.Write(lsbTest.SelectedIndex);&#xD;
		}&#xD;
and it's (0 - giving me the value of the item that i did click.&#xD;
&#xD;
See if you can get this to work and maybe go from there?</description>
      <pubDate>Mon, 14 Nov 2005 19:36:38 GMT</pubDate>
      <guid isPermaLink="false">http://dotnutz.tribe.net/thread/ef291caa-7aab-4604-b199-50e5b974aa0d#3db5d340-4fc6-43cc-9aa2-6fde9a9ec7b4</guid>
      <dc:creator>ben</dc:creator>
      <dc:date>2005-11-14T19:36:38Z</dc:date>
    </item>
    <item>
      <title>Need a little help</title>
      <link>http://dotnutz.tribe.net/thread/ef291caa-7aab-4604-b199-50e5b974aa0d#ef72f9df-8983-4601-a740-98a028f8a51f</link>
      <description>I am working on an application where I want to populate a list, have teh user select one of the items and then act on that selection.  I have created a list box and I populated it with text and values, but when I select an item from the list, the selected index does not change.  I have tried multiple times, but each time the selected index does not change.  I will post the list box definition and the c# code I am using below.  I have gotten the code to execute the ListBox1_SelectedIndexChanged method, but the ListBox1.selectedIndex is always -1.  Any help would be appreciated.&#xD;
&#xD;
ListBox Definition:&#xD;
&#xD;
&amp;amp;lt;asp:ListBox id="ListBox1" style="Z-INDEX: 101; LEFT: 184px; POSITION: absolute; TOP: 168px"&#xD;
				runat="server" Width="336px" AutoPostBack="True"&gt;&amp;amp;lt;/asp:ListBox&gt;&#xD;
&#xD;
&#xD;
c# code:&#xD;
&#xD;
private void Page_Load(object sender, System.EventArgs e)&#xD;
		{&#xD;
			&#xD;
			ListBox1.DataSource = LoadGames();&#xD;
			ListBox1.DataTextField = "GameName";&#xD;
			ListBox1.DataValueField = "GameNumber";&#xD;
			ListBox1.DataBind();&#xD;
		}&#xD;
&#xD;
		&#xD;
		public SqlDataReader LoadGames()&#xD;
		{&#xD;
			SqlCommand myCommand;&#xD;
			SqlDataReader myDataReader;&#xD;
  &#xD;
			sqlConnection1.Open();&#xD;
			//prepare sql statements&#xD;
			myCommand = new SqlCommand("SELECT * FROM Games WHERE NumberOfPlayers &amp;lt; MaxPlayers", sqlConnection1);&#xD;
			myDataReader = myCommand.ExecuteReader(&#xD;
				CommandBehavior.CloseConnection);&#xD;
  &#xD;
			return myDataReader; &#xD;
		}&#xD;
&#xD;
		private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)&#xD;
		{&#xD;
		&#xD;
			Label1.Text = "Fired";&#xD;
		}</description>
      <pubDate>Fri, 11 Nov 2005 03:57:36 GMT</pubDate>
      <guid isPermaLink="false">http://dotnutz.tribe.net/thread/ef291caa-7aab-4604-b199-50e5b974aa0d#ef72f9df-8983-4601-a740-98a028f8a51f</guid>
      <dc:creator>Scott</dc:creator>
      <dc:date>2005-11-11T03:57:36Z</dc:date>
    </item>
  </channel>
</rss>



