Thanks Cathi. I guess that it's better to make it work then to fuss with the wizards!
>Stephen,
>
>The code I supplied would be placed in the Page_Load (code-behind) method. My preference is to write the information in code instead of using the wizards, to have better control of how the code is run.
>
>>I am following along with your sample. I am in the .NET IDE and when I click on the Web Designer Generated code I see most of what you supplied. I guess the point I'm missing is in the IDE, are you setting these commands from the "avaliable GUI assisted options", or do I go to the code behind and crank in this code to get the job done? Am I making a mistake with the IDE thinking that you can do most of it there?
>>
>>__Stephen
>>
>>>You can use a DataReader to fetch the records and populate the listbox. You want to only fetch the records the first time the page is rendered since the data won't change. Here is some sample code:
>>>
>>>
>>>//Only run the code if this is the first time the page is rendered
>>>if (Page.IsPostBack == false)
>>>{
>>> SqlConnection cnn = new SqlConnection(connStr);
>>> string strSQL = "SELECT * FROM Authors";
>>> SqlCommand cmd = new SqlCommand(strSQL, cnn);
>>> SqlDataReader dr;
>>>
>>> cnn.Open();
>>> dr = cmd.ExecuteReader( CommandBehavior.CloseConnection);
>>>
>>> while ( dr.Read() )
>>> {
>>> lstDemo.Items.Add(string .Format("{0}: {1}, {2}",dr("Au_Id"), dr("Au_lname"), dr("Au_fname")));
>>> }
>>>
>>> dr.Close();
>>>}
>>>
>>>
>>>>I have a a page where the listbox is a Select distinct row from a table used in a SQLServer Data connection.
>>>>
>>>>How do I get the thing populated on load of the form? Should I create a special reader?
>>>>
>>>>TIA
>>>>
>>>>__Stephen