[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-07-24
4
Medium Priority
?
915 Views
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.
0
Comment
Question by:bemara57
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
sabeesh earned 800 total points
ID: 19561873
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" />
0
 
LVL 12

Assisted Solution

by:renjurdevan
renjurdevan earned 600 total points
ID: 19562660
well
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

http://forums.asp.net/p/1131368/1814877.aspx

regards
Renju
0
 
LVL 2

Assisted Solution

by:sakshi_net
sakshi_net earned 600 total points
ID: 19569623
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
AlternatingItemTemplate
EditItemTemplate
FooterTemplate
HeaderTemplate
InsertItemTemplate
ItemTemplate

<asp:TemplateField HeaderText="Area" SortExpression="Area">
    <ItemTemplate>
      """
    </ItemTemplate>
    <EditItemTemplate>
      """
    </EditItemTemplate>
    <InsertItemTemplate>
      """
    </InsertItemTemplate>
</asp:TemplateField>

BoundField
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



0
 
LVL 2

Expert Comment

by:sakshi_net
ID: 19569730
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 ?
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month19 days, 12 hours left to enroll

873 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