.Net, ADO.NET, ASP.NET, C#, DataSet, DataTable, Example Connection, GridView, Programming, Visual Studio 2010, Web Development, WebForms

C# Example of a GridView Tied to a SQLDataSource

GridView Example
GridView Example

So what’s the simplest way to build a Web-based interface for a basic database table? In this article I’ll provide a fully working example with a minimum of code.

This is a useful feature to be able to put together, especially when you are catering to power users who should be able to help maintain their own data without needing to call you each time. Continue reading “C# Example of a GridView Tied to a SQLDataSource”

.Net, Ajax, ASP.NET, Checkbox, Dialog, GridView, JavaScript, JQuery, Programming, VB.NET, Web Development, WebForms

Use a JQuery Modal Form Dialog to Add Rows to a GridView Control

JQuery Form Dialog with GridView
JQuery Form Dialog with GridView

Hooking up a JQuery Form Dialog Widget to an ASP.NET GridView Control

Let’s face it: the stock ASP.NET GridView control has some behaviors and limitations that aren’t exactly optimal. For starters, the lack of a nice way for users to add new rows to the grid is unfortunate. There are, of course, several different work-arounds for this all of which have their pros and cons.

I have been testing out using the JQuery Modal Form dialog widget as an input mechanism for new GridView rows. This has the benefit of not requiring the use of ASP.NET’s heavyweight ViewState and constant back and forth communication with the Web Server. Also, the modal nature of the widget on the Web form is a benefit.

The obvious drawback of using client side code is that the newly added rows are not stored in ViewState and you will need to handle them yourself. This really isn’t a big deal if you consider using Ajax calls to a Web Service rather than a complete form submission.

Continue reading “Use a JQuery Modal Form Dialog to Add Rows to a GridView Control”

.Net, ASP.NET, CSS3, GridView, HTML, iTextSharp, JavaScript, PDF, Programming, Reports, Software, Technology, VB.NET, Visual Studio 2010, Web Development

Generate a PDF from an ASP.NET Web Page using the iTextSharp XMLWorker Namespace

If you need to quickly and easily generate PDF documents from ASP.NET, then the iTextSharp library for .NET is very convenient. To install and start using iTextSharp, you can download the zipped reference files from the SourceForge Web site and then add them to your Visual Studio project the same way as you would do with any other third party library file.

The latest version of iTextSharp has deprecated the older HTMLWorker object in favor of the newer XMLWorkerHelper object. This is good news for any developer who likes to use CSS formatting. Although the CSS support is still basic, it is a definite step up from the earlier version of the object which did not support CSS at all. For example, the new object allows a number of important behaviors such as PDF page breaks that were impossible to do using the older object.

To make use of the XMLWorkerHelper object you will need to reference two DLL files in your Visual Studio project. These are:

  1. itextsharp.dll
  2. itextsharp.xmlworker.dll

Once you have referenced these two libraries you are ready to start coding.

In this article I provide a fully working example in both C# and VB.NET. Each example consists of a report page that outputs a simple table, and the main PDF generation page. See the explanation below for further details.

Just to note: if you are interested in further information about iTextSharp then please have a look at the collection of articles I’ve written that cover using iTextSharp for .NET PDF generation.

Continue reading “Generate a PDF from an ASP.NET Web Page using the iTextSharp XMLWorker Namespace”