How to export a GridView to an HTML file?

How to export a GridView to an HTML file?

When the Export Button is clicked, the GridView is rendered into an HTML string using the StringWriter, HtmlTextWriter and the RenderControl function. Then the HTML string is written to the HTTP Response and eventually exported as an HTML (.htm) file. //Download the HTML file. ‘Download the HTML file. No comments have been added to this article.

How can web user control be used in GridView control?

In this article I will share how a Web User Control can be used in the GridView control. The examples are written using C# . Developing some web site we often should use some control in the GridView control. In this case we have to create the GridView control with TemplateField columns and use some special methods to access needed data.

How to set DataSource in GridView control?

Again we use FindControl method: DataTable dtInside = ( (UserControls_ListBoxesFT_C)GridView1. We use this method to set the DataSource property of the GridViewTestDT_Out control when we click on the button ButtonTestDTOut: Now we can test how our control works inside the GridView control.

Where is the GridView control in the templatefield?

The fourth column is the TemplateField and contains GridView control with Id = “GridView_Inside”, which allows to display the C_DataOut property of the ListBoxesFT_C2 for selected row; the HeaderText property of this column is “Test_GridView”.

When the Export Button is clicked, the GridView is rendered into an HTML string using the StringWriter, HtmlTextWriter and the RenderControl function. Then the HTML string is written to the HTTP Response and eventually exported as an HTML (.htm) file. //Download the HTML file. ‘Download the HTML file. No comments have been added to this article.

What can you do with templatefield in GridView?

Using TemplateField, you can add HTML, DataBinding expressions, or ASP.NET controls in GridView. You can customize the user interface and add validation logic to the fields. Let us take an example in which user can select one or more checkbox to delete the record. For doing this first we will add TemplateField in the GridView.

Which is HTML editor control do you use?

HTMLEditor is an ASP.NET AJAX Control that allows you to easily create and edit HTML content via buttons in a toolbar. The goal of this tutorial is to provide you with an overview of the HTML Editor control included with the AJAX Control Toolkit.

Can you use EmpId as a datakey in GridView?

In this example EmpID is used as DataKeys, that’s why it is non-editable. You can provide DataKeys property of GridView form property window of GridView control. Using TemplateField, you can add HTML, DataBinding expressions, or ASP.NET controls in GridView.