Hi everyone, i have a list box that is populated with the names of companies and once the user select's one, textboxes are populated with the relevant information(a query is used to select all information from the database where company = the selected item in the listbox).
Now i have not experienced any problems with the code so far except now, the code has been used for several other parts of the application.
basic code for the functionality mentioned.
except now the following exception has occured:
ArguementOutOfR angeException:
InvalidArgument =Value of '2' is not valid for 'SelectedIndex' .
Parameter name: SelectedIndex
i have searched the web for a solution but so far, no clear, concise explanation for this issue has been found.
Suggestions anyone? or maybe a link to an article to read up on this matter? its really frustrating.
Now i have not experienced any problems with the code so far except now, the code has been used for several other parts of the application.
Code:
list = sender as ListBox;
if (list.SelectedIndex != -1)
{
LBox_Cus_LookUp.SelectedIndex = list.SelectedIndex;
DBcon.Open();
DBcmd.CommandText = "select * from Supplier where sup_company = '" + LBox_Sup_LookUp.SelectedItem.ToString() + "' ";
DB_dr = DBcmd.ExecuteReader();
if (DB_dr.HasRows)
{
while (DB_dr.Read())
{
//populate the textboxes
TxtBoxSup_ID.Text = DB_dr[0].ToString();
TxtBoxSup_Company.Text = DB_dr[1].ToString();
TxtBoxSup_Address.Text = DB_dr[2].ToString();
TxtBoxSup_City.Text = DB_dr[3].ToString();
TxtBoxSup_Phone_No.Text = DB_dr[4].ToString();
TxtBoxSup_Fax.Text = DB_dr[5].ToString();
TxtBoxSup_Postal.Text = DB_dr[6].ToString();
TxtBoxSup_Email.Text = DB_dr[7].ToString();
}
}
DBcon.Close();
}
except now the following exception has occured:
ArguementOutOfR angeException:
InvalidArgument =Value of '2' is not valid for 'SelectedIndex' .
Parameter name: SelectedIndex
i have searched the web for a solution but so far, no clear, concise explanation for this issue has been found.
Suggestions anyone? or maybe a link to an article to read up on this matter? its really frustrating.
Comment