In ASP.Net 2.0 Datagrid control is being renamed as Gridview Control. But there are some differences in ASP.Net 2.0 Gridview control. 3 main differences are
ASP.Net 2.0 has introduced 3 new column fields:
1. Checkbox field
2. Image field
3. Command Field
Following is an example view of commonly used fields and their attributes of ASP.Net Gridview control:
code:html
------------------------------------------
<asp:GridView ID="GridView1" runat="server" AllowPaging="true" AutoGenerateColumns="false">
<Columns>
<asp:CheckBoxField DataField="" />
<asp:ImageField DataImageUrlField="">
</asp:ImageField>
<asp:BoundField DataField="" />
<asp:ButtonField DataTextField="" ButtonType="Link" />
<asp:HyperLinkField DataTextField="" NavigateUrl="" />
<asp:TemplateField>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "")%>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="Numeric" />
</asp:GridView>
----------------------------------------------------------------------------------
Generally Bound Field column is used to display the tabulated read only view of the data retrieved from the database. You can use SQL Database easily to bind the data stored in SQL database. Ms Access Database can also be used to save the small scale data and bind the data with Gridview Control.
For an easy setup to bind the data with Gridview control you can setAutoGenerateColumns="false" to display the fields retrieved from the SQL Query.
This will automatically display the read-only view of data retrieved and automatically renders the appropriate control such as checkbox for bit datatype fields having value in the form of 0/1 or true/false.
To customize the view of data you can use the Template field. Div layout or tablescan be used inside the ItemTemplate to generate the structured view of data retrieved from the database.
Code - C#
----------------------------------------------------
<%#DataBinder.Eval(Container.DataItem, "DATABASE FIELD NAME")%>
---------------------------------------------
Above syntax can be used to bind the retrieved field in ASP.Net 2.0 Gridview ItemTemplate control.