protected void Page_Load(object sender, EventArgs e) { if (!(Page.IsPostBack)) { string strXML; PortfolioService objectService = new PortfolioService(); string strParam = Session["selectedstock"].ToString(); strXML = objectService.GetStockInfoByTicker(strParam); XElement xmlstockrecord = XElement.Parse(strXML); XElement xmlstock = xmlstockrecord.Element("Stock"); XElement xmlstockticker = xmlstock.Element("Ticker"); XElement xmlstockCusip = xmlstock.Element("Cusip"); XElement xmlstockVolume = xmlstock.Element("Volume"); XElement xmlstockEPS = xmlstock.Element("EPS"); XElement xmlstockSector = xmlstock.Element("Sector"); XElement xmlstockCompanyName = xmlstock.Element("CompanyName"); XElement xmlstockCountry = xmlstock.Element("Country"); lblTicker.Text = xmlstockticker.Value.ToString(); lblCusip.Text = xmlstockCusip.Value.ToString(); lblVolume.Text = xmlstockVolume.Value.ToString(); lblEps.Text = xmlstockEPS.Value.ToString(); lblSector.Text = xmlstockSector.Value.ToString(); lblCompany.Text = xmlstockCompanyName.Value.ToString(); lblCountry.Text = xmlstockCountry.Value.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { string strXML; PortfolioService objectService = new PortfolioService(); if (Request.QueryString.ToString().Contains("company")) { strXML = objectService.GetStockInfoByCompanyName(Request.QueryString["company"]); } else if (Request.QueryString.ToString().Contains("ticker")) { strXML = objectService.GetStockInfoByTicker(Request.QueryString["ticker"]); } else strXML = objectService.GetStockInfoByCUSIP(Request.QueryString["cusip"]); XElement stock = XElement.Parse(strXML); var query = from c in stock.Elements("Stock") select new { Ticker = c.Element("Ticker").Value, Company= c.Element("CompanyName").Value, Country = c.Element("Country").Value }; string strPath = Request.PhysicalApplicationPath; // stock.Save(strPath + "securityoffers.xml"); // Response.Write("<a href='securityoffers.xml'>View XML file</a>"); int count1 = query.Count(); if (count1 == 0) { Label1.Visible = true; Label1.Text = "No record Found."; HyperLink1.Visible = true; HyperLink1.Text = "Click to go back To Previous Page"; HyperLink1.NavigateUrl = "~/SearchStock.aspx"; } gvstock.DataSource = query; gvstock.DataBind(); if (count1 == 1) { Session["selectedstock"] = query.First().Ticker; Response.Redirect("DisplayDetailStock.aspx"); } }