void DisplayUsers() { clsCustomerCollection Customers = new clsCustomerCollection(); CustomerListBox.DataSource = Customers.CustomerList; CustomerListBox.DataValueField = "CustomerId"; CustomerListBox.DataTextField = "Name"; CustomerListBox.DataBind(); }
/// <summary> /// Dispalys the customer list in the ListBox /// </summary> void DisplayCustomers() { //create instance of customer collection clsCustomerCollection collection = new clsCustomerCollection(); //set the listbox to the database list CustomerListBox.DataSource = collection.CustomerList; //set the name of the primary key CustomerListBox.DataValueField = "cusId"; //set the data field to display CustomerListBox.DataTextField = "cusName"; //bind data to list CustomerListBox.DataBind(); }
//btn apply filter click protected void btnApplyFilter_Click(object sender, EventArgs e) { //create an instance of the address collection clsCustomerCollection collection = new clsCustomerCollection(); //filter the collection by the input collection.ReportByEmail(txtFilter.Text); //set CustomerListBox data source to new filtered list CustomerListBox.DataSource = collection.CustomerList; //set the name of the primary key CustomerListBox.DataValueField = "cusId"; //State the name of the field to display CustomerListBox.DataTextField = "cusEmail"; //bind the data to the list CustomerListBox.DataBind(); }
//btn clear filter click protected void btnClearFilter_Click(object sender, EventArgs e) { //create an instance of the customer collection clsCustomerCollection data = new clsCustomerCollection(); //filter data.ReportByEmail(""); //clear any existing filter to tidy up the interface txtFilter.Text = ""; //set the data source CustomerListBox.DataSource = data.CustomerList; //set the name of the primary key CustomerListBox.DataValueField = "cusId"; //set the name of the field to display CustomerListBox.DataTextField = "cusName"; //bind the data to the list CustomerListBox.DataBind(); }