protected void BasketList_PreRender(object sender, EventArgs e) { //Configuring Data Source for the ListView string connectionString = ConfigurationManager.ConnectionStrings[dbCommander.sourceString].ConnectionString; if (Session["Basket"] != null) { List <string> venuesBasket = (List <string>)Session["Basket"]; if (venuesBasket.Count == 0) { ids = "00000000-0000-0000-0000-000000000000"; } else { //Creating string from VenueID list in session ids = string.Join("','", ((List <string>)Session["Basket"]).ToArray()); } } else { ids = "00000000-0000-0000-0000-000000000000"; } //Passing the string of ids to the query query = String.Format("SELECT * FROM Venues INNER JOIN Customers ON Venues.CustomerID = Customers.CustomerID WHERE VenueID IN ('{0}')", ids); SqlDataSource source = new SqlDataSource(connectionString, query); BasketList.DataSource = source; BasketList.DataBind(); dbCommander.CloseConnection(); }