protected void Page_Load(object sender, EventArgs e) { try { if (Request.QueryString["val"] != null && Request.QueryString["val"].ToString().Trim() != "") { //string val = Request.QueryString["val"].ToString().Trim(); //string DecryptQueryString = CommonHelper.Decrypt(val); string DecryptQueryString = Request.QueryString["val"].ToString().Trim(); string[] queryStringData = DecryptQueryString.Split('|'); string type = queryStringData[0]; string fileName = string.Empty; DataSet ds = new DataSet(); switch (type) { case "users": // UserBO objUserBO = new UserBO(); objUserBO.UserID = queryStringData[1]; objUserBO.CompId = Convert.ToInt32(queryStringData[2]); objUserBO.Role = queryStringData[3]; ds = CommonBL.GetUsers(objUserBO); string[] selectedColumns = new[] { "FirstName", "EmailID", "Gender", "DeptName", "TeamName", "Manager", "StartDate" }; DataSet newDS = new DataSet(); newDS.Tables.Add(new DataView(ds.Tables[0]).ToTable(false, selectedColumns)); fileName = "UserList"; ExportToExcel(newDS, fileName); break; } } else { ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Oops... Something went wrong.');window.close();", true); } } catch (Exception ex) { } finally { } }