![]() ![]() In the Configure your new project dialog, name the project TodoApi and select Next.Select the ASP.NET Core Web API template and select Next.From the File menu, select New > Project.HttpContext context = HttpContext.Current Ĭ = "application/pdf" Ĭontext.Response. PdfTab.HorizontalAlignment = 1 // 0- Left, 1- Center, 2- rightĭata = dc.CityDatas.OrderBy(a => a.Country).ThenBy(a => a.State).ThenBy(a => a.City).ToList() īyte content = File.ReadAllBytes(filePath) PdfPTable pdfTab = new PdfPTable(4) // here 4 is no of column Create table here for write database data PdfWriter.GetInstance(doc, new FileStream(filePath, FileMode.Create)) Paragraph p = new Paragraph("Export Database data to PDF file in ASP.NET") Create paragraph for show in PDF file header String filePath = Path.Combine(Server.MapPath("~/PDFFiles"), fileName) ĭocument doc = new Document(PageSize.A4, 2, 2, 2, 2) ![]() String fileName = Guid.NewGuid() + ".pdf" This code is for export Database data to PDF file Protected void btnExport_Click(object sender, EventArgs e) ![]() Step-8: Write below code in button click (btnExportPDF_Click) event for export Database data to PDF File. Right Click on references under project folder > Add Reference > Select itextsharp.dll > OK. Var v = dc.CityDatas.OrderBy(a => a.Country).ThenBy(a => a.State).ThenBy(a => a.City).ToList() Using (MyDatabaseEntities dc = new MyDatabaseEntities()) Protected void Page_Load(object sender, EventArgs e) Step-6: Write following code in Page_Load event for Show data in Gridview. Go to Solution Explorer > Right Click on Project name form Solution Explorer > Add > New item > Select web form/ web form using master page under Web > Enter page name > Add. Step-5: Add a Webpage and Design for Show Data in Gridview & Export to PDF Go to Solution Explorer > Right Click on Project name form Solution Explorer > Add > New item > Select ADO.net Entity Data Model under data > Enter model name > Add.Ī popup window will come (Entity Data Model Wizard) > Select Generate from database > Next >Ĭhose your data connection > select your database > next > Select tables > enter Model Namespace > Finish. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |