protected void BtnApply_Click(object sender, EventArgs e) { clsCustomerCollection Customers = new clsCustomerCollection(); lblError.Text = ""; string CustomerID = txtCustomerID.Text; int ID = 0; bool test = int.TryParse(CustomerID, out ID); if (test == false) { lblError.Text = "Please enter a valid Customer ID"; } else { ID = Convert.ToInt32(CustomerID); Customers.ReportByCustomerID(ID); } lstCustomerList.DataSource = Customers.CustomerList; lstCustomerList.DataValueField = "CustomerID"; lstCustomerList.DataTextField = "allProperties"; lstCustomerList.DataBind(); if (lstCustomerList.Items.Count <= 0) { lblError.Text = "There are no customers with the ID " + CustomerID; } }