what is ItemTemplate and EditTemplate and FooterTemplate?
what is the Purpose of useing template columns in datagrid?

Answer Posted / swathi .m

DataGrid's Templated Columns
Template-based columns in a Web DataGrid control play
an important role as they allow you to add a freeform
column type to the DataGrid. Normally, the DataGrid control
displays all of its contents through plain text strings (as
BoundColumns), or through one of the pre-defined column
types. However, sometimes the pre-defined column types just
don't provide the representation the page developer is
after. A templated column can define up to four different
templates, as explained in Figure 1. You will likely use
the ItemTemplate most frequently. It defines how the nth
cell of the column will draw and what its contents will be
in terms of constituent controls. HeaderTemplate and
FooterTemplate are rather self-explanatory. The
EditItemTemplate property lets you specify how the cell
will change when the parent row is put into edit mode. Note
that, unlike the DataList control, the DataGrid does not
feature a template for the selected state.
Your DataGrid control should use template-based
columns when you need to do something in a nonstandard way
throughout the whole column. If you need to display data in
a way that none of the base column types provide for (text,
buttons, hyperlinks), then templated columns are your best
choice.
Figure 1 DataGrid Column Templates
Name Description
ItemTemplate Contains the template for the items in a
DataGrid's column.
<ItemTemplate>
<asp:label runat="server" text= '<%# ... %>'...>
</ItemTemplate>
You can use any combination of HTML text and ASP.NET
controls to populate the column.
EditItemTemplate Controls the contents of the item
selected for editing in the column of the DataGrid control.
Place the controls you need for editing the cell between
the opening and closing EditItemTemplate tags.
<EditItemTemplate>
<asp:textbox runat="server" text= '<%# ... %>'...>
</EditItemTemplate>
HeaderTemplate Contains the template for the heading
section.
<HeaderTemplate>
<asp:label runat="server" text= "Header"...>
</HeaderTemplate>
If you omit this template, the column header is rendered
with a label or a hyperlink if sorting is enabled. By
specifying a custom template, you make yourself responsible
to provide the user interface needed to enable sorting on
the column.
FooterTemplate Contains the template for the footer
section of the column. The default value is a null
reference.
<FooterTemplate>
<asp:label runat="server" text= "..."...>
</FooterTemplate>
The footer is displayed only if the ShowFooter property of
the DataGrid is set to True.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When displaying fonts, what is the difference between pixels, points and ems?

570


Explain what is mutex?

602


What data providers available in .net to connect to database?

539


Can I write my own .net host?

638


Explain me difference between public and static modifiers?

530






i had attended to infosys interview on 17th april 2010...on .net..3+ experience for Technology Analyst .. to my knowledge i did well in technical and hr whether i loose the interview or still processing is taking place..am confused please. what accuatly would be happend?

1950


Explain what do the terms “boxing” and “unboxing” mean?

585


What is iis? Have you used it?

582


Please explain what do the terms “boxing” and “unboxing” mean?

603


Explain me what is .net web service?

567


How to implement datagrid in.net? How would you make a combo-box appear in one column of a datagrid? What are the ways to show data grid inside a data grid for a master details type of tables? If we write any code for datagrid methods. What is the access specifier used for that methods in the code behind file and why?

557


How many namespaces are in .net version 1.1?

621


Who is using .net core?

547


Explain the .net framework overview?

583


Explain different types of html, web and server controls.

576