public void CallStock() { PortfolioService wsbobjservice = new PortfolioService(); string strusername = Session["username"].ToString(); String strportfolio = wsbobjservice.GetPortfolioByUserName(strusername); XElement portfolio = XElement.Parse(strportfolio); var query = from t in portfolio.Elements("Stock") select new { Ticker = t.Element("Ticker").Value, companyname = t.Element("CompanyName").Value, country = t.Element("Country").Value }; int count1 = query.Count(); if(count1==2) { String ticker1 = query.First().Ticker; String ticker2 = query.Last().Ticker; Session["ticker1"] = ticker1; Session["ticker2"] = ticker2; } gvPortfolio.DataSource = query; gvPortfolio.DataBind(); String stremployee = wsbobjservice.GetEmployeeIDByUserName(strusername); XElement employee = XElement.Parse(stremployee); string strPath = Request.PhysicalApplicationPath; employee.Save(strPath + "employee.xml"); //Response.Write("<a href='employee.xml'>View employee</a>"); var query1 = from c in employee.Elements("Customer") select new { EMP_ID = c.Element("EMP_ID").Value, }; string empid = query1.First().EMP_ID; if (empid != null) { EmpId = Convert.ToInt32(empid); } //GridView1.DataSource = query1; //GridView1.DataBind(); }