Tuesday, December 31, 2019

Datatable to excel Download

public static void ExcelPrintWithSubReport(string SpName, DataTable dataSource)
        {

            GridView gv = new GridView();
            gv.DataSource = dataSource;
            gv.DataBind();

            SpName = SpName + ".xls";

            HttpContext context = System.Web.HttpContext.Current;
            context.Response.ClearContent();
            context.Response.Buffer = true;
            context.Response.AddHeader("content-disposition", "attachment; filename= CheckData.xls");
            context.Response.ContentType = "application/ms-excel";
            context.Response.Charset = "";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gv.RenderControl(htw);
            context.Response.Output.Write(sw.ToString());
            context.Response.Flush();
            htw.Close();
            sw.Close();
            context.Response.End();

        }// End of Method

Delete Data From Joining Tables

Delete ev   FROM Evaluation AS ev
Inner Join Employee AS e ON ev.EmployeeId = e.EmployeeId
 WHERE
 e.OfficeId IN ( SELECT OfficeId FROM Office WHERE ThirdLevel = 2790 AND IsActive = 1 )
 AND ev.Year = 2019
 AND ev.EvaluationPeriodShort = 'D'

Screen Record

 Windows Screen Record WindowsKey+ Alt + R Recording Starts.