private void PopulateLogType()
 {
     try
     {
         LogController objController = new LogController();
         ddlLogType.DataSource = objController.GetLogType();
         ddlLogType.DataValueField = "LogTypeID";
         ddlLogType.DataTextField = "Name";
         ddlLogType.DataBind();
         ddlLogType.Items.Insert(0, new ListItem("ALL", "-1"));
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
 private void BindGrid()
 {
     string logType = string.Empty;
     if (ddlLogType.SelectedValue != "-1")
     {
         logType = ddlLogType.SelectedItem.Text;
     }
     try
     {
         LogController objController = new LogController();
         gdvLog.DataSource = objController.GetLogView(GetPortalID, logType);
         gdvLog.DataBind();
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
        private void ExportToExcel()
        {
            string table = "";
            string logType = string.Empty;
            if (ddlLogType.SelectedValue != "-1")
            {
                logType = ddlLogType.SelectedItem.Text;
            }
            try
            {
                List<LogInfo> lstInfo = new List<LogInfo>();
                LogController objCon = new LogController();
                lstInfo = objCon.GetLogView(GetPortalID, logType);
                if (lstInfo.Count > 0)
                {                    
                    table += "<table><tr><th>Log ID</th><th>AddedOn</th><th>LogTypeName</th><th>Portal Name</th><th>Client IP Address</th><th>Page URL</th><th>Exception</th></tr>";
                    foreach (LogInfo objInfo in lstInfo)
                    {
                        table += " <tr>";
                        table += "<td>";
                        table += objInfo.LogID;
                        table += "</td>";
                        table += "<td>";
                        table += objInfo.AddedOn;
                        table += "</td>";
                        table += "<td>";
                        table += objInfo.LogTypeName;
                        table += "</td>";
                        table += "<td>";
                        table += objInfo.PortalName;
                        table += "</td>";
                        table += "<td>";
                        table += objInfo.ClientIPAddress;
                        table += "</td>";
                        table += "<td>";
                        table += objInfo.PageURL;
                        table += "</td>";
                        table += "<td>";
                        table += objInfo.Exception;
                        table += "</td>";
                        table += "</tr>";                       
                    }
                    table += "</table>";
                }
                ExportToExcel(ref table, "Event Log-Report");
            }
            catch (Exception ex)
            {
                throw ex;
            }


        }