Wednesday, December 9, 2009

GridView / DataList Control

GridView Control
The GridView control displays data as a table and provides the capability to sort columns, page through data, and edit or delete a single record. the GridView control offers improvements such as the ability to define multiple primary key fields, improved user interface customization using bound fields and templates, and a new model for handling or canceling events
datagrid and gridview both have same functionality to display your data in the form of a table.
Datagrid is used in Windows Application whereas gridview is used in Web Applications.

The GridView control is the workhorse of the ASP.NET 2.0 Framework. It is one of
the most feature-rich and complicated of all the ASP.NET controls. The GridView
control enables you to display, select, sort, page, and edit data items such as
database records.
You also get the chance to tackle several advanced topics. For example, we can highlight certain rows in a GridView depending on the data the row represents.
  • No code required.
  • No code required for PageIndexChanged.
  • Needs little code for update operation.
  • GridView supports events fired before and after database updates
Datagrid..
  • Code requires to handle the SortCommand event and rebind grid required.
  • Code requires to handle the PageIndexChanged.
  • Need extensive code for update operation on data.
  • When compared to gridview less events supported.

GridView is new version and extension of earlier asp.net 1.1 Gridview in ASP.NET
2.0 and onwards versions.
GridView is used for control, editing data, your own custom template, sorting kind
of scenarios but you can not customize everything.

<asp:GridView ID="GridView1" runat="server">
<EmptyDataTemplate>
</EmptyDataTemplate>
<Columns>
<asp:BoundField />
<asp:ButtonField />
<asp:CheckBoxField />
<asp:CommandField />
<asp:HyperLinkField />
<asp:ImageField>
</asp:ImageField>
<asp:TemplateField>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
</ItemTemplate>
<AlternatingItemTemplate>
</AlternatingItemTemplate>
<InsertItemTemplate>
</InsertItemTemplate>
<EditItemTemplate>
</EditItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<PagerTemplate>
</PagerTemplate>
</asp:GridView>

No comments:

Post a Comment