Export gridview data to Excel document in asp.net C#


Follow the  steps involved :

Step 1:

Create a aspx page with a grid view control.

ViewExcelReport.aspx

aspx code

 Step 2:
Add the code for the button click in ViewExcelReport.aspx.cs

code

Now you are done, you can export the grid view in to Excel format.

if you’re getting any error message like

RegisterForEventValidation can only be called during Render();

To solve, add the overriding function VerifyRenderingInServerForm event in code. 

Thanks for reading this article!! please leave your comments and suggestion about this article.

 

Validate EmailAddress in Asp.net using RegularExpressionValidator Control


Here are the steps to validate EmailAddress in Asp.net using RegularExpressionValidator Control.


Step 1 :
  Add a RegularExpressionValidator control to your web page.

Step 2: 

         Right click on the control and select properties.

    • Set the ControlToValidate property to indicate which control to validate.
    • Set the ValidationExpression property to  regular expression as shown
      in below image.