-->![Gridview Templates In Asp Net Gridview Templates In Asp Net](/uploads/1/2/6/3/126366156/337541964.png)
Assume that you already have a data source SqlDataSource1 that binds to a simple query returning some details from the Customers table.
In Visual Studio, if you add a GridView control to a web forms page in Design View and choose SqlDataSource1 as the Data Source (as shown in figure 1 below), typically the GridView columns are generated as asp:BoundField types in source.
Aug 29, 2018 In this article I will explain how to dynamically add BoundField and TemplateField column to GridView in ASP.Net using C# and VB.Net. Dynamic BoundField and TemplateField columns will be created and then added to GridView after that the GridView will be populated from database.
Figure 1
[![ChooseDataSource](https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/webdevelopertips/WindowsLiveWriter/Tip64DidyouknowHowtoconvertaGridViewcolu_8EB0/ChooseDataSource_thumb.jpg 'ChooseDataSource')](https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/webdevelopertips/WindowsLiveWriter/Tip64DidyouknowHowtoconvertaGridViewcolu_8EB0/ChooseDataSource.jpg)
Often, you want to customize one or more columns by converting them into an asp:TemplateField rather than asp:BoundField. Let’s say you want to convert the Email column into a asp:TemplateField.
You can quickly do this in Design View by clicking on ‘Edit Columns’ in the Smart Tasks panel of the GridView, select the ‘Email’ field in the dialog that pops up and click on ‘Convert this field into a TemplateField’, then click ‘OK’.
Figure 2
Figure 3
The source for the field Email will now be updated to:
![Gridview Templates In Asp Net Gridview Templates In Asp Net](/uploads/1/2/6/3/126366156/337541964.png)
You can also do a similar thing with the DetailsView control by choosing the ‘Edit Fields’ item in the Smart Tasks panel of the DetailsView control.
Bala Chirtsabesan
SDET | Visual Web Developer