mmalling
July 10th, 2003, 12:35 PM
I'm new to ASP.NET and C#.
I'm writting my first ASP.NET WebApplication. My problem is that I have a bunch of controls, but two in particular. A ListBox and a DropDownList. They are both populated by querying two different tables on a SQL server. My problem is that the itmes in both lists get duplicated by one everytime I totally close and restart the web page. The only way I get the correct number of items to display is to make a change to the ASP.NET code and rebuild it. Then everytime after the control itmes are duplicatedd again. I've tried turing off the viewstate for each control and for the entire page with no results.
These data items are primary keys int he SQL tables so I know the data is not duplicated, its the .NET control thats duplkicating the values. Any help ?
Here is the code I'm using to fill the ListBox:
string Query;
Query="SELECT * FROM "+TeamName+"Queue";
OleDbDataAdapter SQLData = new OleDbDataAdapter(Query,ConnString);
SQLData.Fill(DraftDataSet,TeamName+"Queue");
DraftQueue.Items.Clear();
for(int x=0;x<=DraftDataSet.Tables[TeamName+"Queue"].Rows.Count;x++)
DraftQueue.Items.Add(Convert.ToString(DraftDataSet.Tables[TeamName+"Queue"].Rows[x]["PlayerName"]));
The for loop is suppoded to be < not <=...for some reason the code would not post correctly to codegurur unless I changed the < to <=....prob from HTML glitch...
Anyways can anyone help ?
I'm writting my first ASP.NET WebApplication. My problem is that I have a bunch of controls, but two in particular. A ListBox and a DropDownList. They are both populated by querying two different tables on a SQL server. My problem is that the itmes in both lists get duplicated by one everytime I totally close and restart the web page. The only way I get the correct number of items to display is to make a change to the ASP.NET code and rebuild it. Then everytime after the control itmes are duplicatedd again. I've tried turing off the viewstate for each control and for the entire page with no results.
These data items are primary keys int he SQL tables so I know the data is not duplicated, its the .NET control thats duplkicating the values. Any help ?
Here is the code I'm using to fill the ListBox:
string Query;
Query="SELECT * FROM "+TeamName+"Queue";
OleDbDataAdapter SQLData = new OleDbDataAdapter(Query,ConnString);
SQLData.Fill(DraftDataSet,TeamName+"Queue");
DraftQueue.Items.Clear();
for(int x=0;x<=DraftDataSet.Tables[TeamName+"Queue"].Rows.Count;x++)
DraftQueue.Items.Add(Convert.ToString(DraftDataSet.Tables[TeamName+"Queue"].Rows[x]["PlayerName"]));
The for loop is suppoded to be < not <=...for some reason the code would not post correctly to codegurur unless I changed the < to <=....prob from HTML glitch...
Anyways can anyone help ?