Wednesday, 23 April 2014

What is Gridview in Asp.Net

        Gridview control is a structural control and it is in tabular format like Rows and Columns
·        It has very rich features like sorting, paging, editing and updating are provided in “RAD” (Rapid application Development) as well as in programmatic model. In project, we use programmatic model not RAD.
·        The first feature of Gridview is “AutoGeneratingColumn” based on data objects. It has a property called “AutoGeneratingColumn” by default is TRUE. When this is set to False. No output is produced by Gridview on its own.
·        Gridview provides a collection called “Columns” where we can provide it’s structure
·        Column is a collection of Gridiew Fields which are also provided by Gridview.
Important Fields of Gridview are
--- BoundField
--- TemplateField
---  CommandField
  1.  BoundField :  BoundField is the simplest among all fields and it is used to present data objects one field  data. It is simple in presentation i.e Simple text can be displayed and also limited in options.
  2. TemplateField : Unless BoundField, TemplateField is more rich in presenting output’s and it is complex with many options “ it is a collection of Templates”


                             Every Template has a use and we have to understand the use of template and produce the Output.
                              It is also an attribute based and if a task can be performed using an attribute then it is preferred.
                              “TemplateField or It’s templates doesn’t have any attribute for getting data object or data(like datafield of BoundField) So to get data from data object templateField used “Asp.net Data binding Expression”
 There are three main templates in TemplateField
                       a) Header Template
                       b) Item Template
                       c)Edit Template

  1. CommandField : This field will display edit,update,delete and cancel action buttons. It is exclusively used for editing actions for Gridview data.


                              This field is also dependent on edit index. It display edit/delete when editIndex is “-1” for all rows and for n th row is displays update and cancel.

No comments:

Post a Comment