What is the different between a TemplateField and a BoundField in ASP.NET 2.0?

Posted on 2007-07-24
Last Modified: 2013-11-07
I'm wanting to bind an array to a GridView. I'm seeing that there are a few ways to choose the columns in the GridView. What is the different between a TemplateField and a BoundField? I'd appreciate an example for each.. like which one would I use to multiply each field in a column by 10 before binding it.
Question by:bemara57
    LVL 8

    Accepted Solution

    TemplateField use when you want to place control like textbox or label inside the gridview colum and bind data
    <asp:TemplateField HeaderText="Area" SortExpression="Area">
    5                        <EditItemTemplate>
    6                            <asp:DropDownList ID="AreaDropDownList" runat="server"></asp:DropDownList>
    7                        </EditItemTemplate>
    8                        <ItemTemplate>
    9                            <asp:Label ID="AreaLabel" runat="server" ></asp:Label>
    10                       </ItemTemplate>
    11                   </asp:TemplateField>

    BoudField is for directly bound data to your datagrid

    <asp:BoundField DataField="Descrizione" HeaderText="Descrizione" SortExpression="Descrizione" />
    LVL 12

    Assisted Solution

    Templatefields are used for coustomization
    Bound fiels simply bind data from your data source.. you should specify the DataField which you want to bound from data source

    Go through  link

    LVL 2

    Assisted Solution

    Template Column
    TemplateField is used for custom content for each record displayed. It used when you want to display the GridView in a customized format. TemplateField can be used to create customised record display.
    In Templatefield we have customization in

    <asp:TemplateField HeaderText="Area" SortExpression="Area">

    Where as Boundfield Displays data in straight text format. You can always go for bound field if u just want to show a normal gridview display.
    Boundfield provides different properties for Header and Footer customizations.

    You will get more detailed Information about both

    LVL 2

    Expert Comment

    I didnt get the part "which one would I use to multiply each field in a column by 10 before binding it."
    What exactly you are trying to do ?

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now