private void GenerateGridView() { try ///display the table in gridview { string[] products = client.GetProducts((string)DropDownList1.SelectedItem.ToString()); //store all the products in a string array var myproducts = from p in products select new { Product = p }; GridView1.DataSource = myproducts.ToList(); GridView1.DataBind(); } catch { Response.Write("Could not display the products of specified category"); } }