void Bind() { XmlDocument doc = XmlDataSourcePro.GetXmlDocument(); int proPts = 0; foreach (XmlNode node in doc.SelectNodes("/ScoreBoard/Point[@type=\"pro\"]")) { proPts += Convert.ToInt32(node.Attributes["rate"].Value); } int conPts = 0; foreach (XmlNode node in doc.SelectNodes("/ScoreBoard/Point[@type=\"con\"]")) { conPts += Convert.ToInt32(node.Attributes["rate"].Value); } string strStatus = (proPts > conPts) ? "rules" : "sucks"; if (proPts == conPts) { strStatus = "is status quo"; } int dif = System.Math.Abs(proPts - conPts); lblProPts.Text = proPts.ToString(); lblconPts.Text = conPts.ToString(); lblWinner.Text = string.Format("Buenos Aires currently {0} by {1} points", strStatus, dif.ToString()); }
protected void btnSubmit_Click(object sender, EventArgs e) { XmlDocument doc; if (rdoPro.Checked) { doc = XmlDataSourcePro.GetXmlDocument(); XmlNode node = doc.DocumentElement.FirstChild.Clone(); node.Attributes["rate"].Value = Rating1.CurrentRating.ToString(); node.Attributes["txt"].Value = txtEntry.Text; node.Attributes["type"].Value = "pro"; doc.DocumentElement.AppendChild(node); XmlDataSourcePro.Save(); grdPro.DataBind(); } else { doc = XmlDataSourceCon.GetXmlDocument(); XmlNode node = doc.DocumentElement.FirstChild.Clone(); node.Attributes["rate"].Value = Rating1.CurrentRating.ToString(); node.Attributes["txt"].Value = txtEntry.Text; node.Attributes["type"].Value = "con"; doc.DocumentElement.AppendChild(node); XmlDataSourceCon.Save(); grdCon.DataBind(); } txtEntry.Text = string.Empty; Bind(); }