protected void saveBtn_Click(object sender, EventArgs e) { //creating a restaurants object from the session restaurants restaurantList = Session["restaurantListSession"] as restaurants; if (restaurantDropDown.SelectedValue != "0") //if there is a restaurant selected { //create a restaurant object for the selected restaurant and displayin its info restaurantsRestaurant rest = restaurantList.restaurant[restaurantDropDown.SelectedIndex - 1]; rest.summary = summaryTxt.Text; rest.rating.Value = byte.Parse(ratingDropDown.SelectedValue); //creating a string from the xml file string xmlFile = MapPath(@"~/restaurant_reviews.xml"); // serializing (converting from object to xml) the file: using (FileStream xs = new FileStream(xmlFile, FileMode.Create)) { XmlSerializer serializor = new XmlSerializer(typeof(restaurants)); serializor.Serialize(xs, restaurantList); } //text message at the bottle messageLbl.Visible = true; messageLbl.Text = "Revised retaurant review has been saved to " + xmlFile; } }
public void displayRestaurantInfo(restaurantsRestaurant rest) { addressTxt.Text = rest.address.street + "\n" + rest.address.city + "\n" + rest.address.province + "\n" + rest.address.postalCode + "\n"; summaryTxt.Text = rest.summary; ratingDropDown.SelectedValue = rest.rating.Value.ToString(); messageLbl.Visible = false; }