Go to DotNetFunda.com
 Online : 474 |  Welcome, Guest!   Login
 
Home > Articles > ADO.NET > Diff Between DataGrid and GridView

  • Download the OOPS, ASP.NET and ADO.NET online training sessions videos and related document for FREE, click here.

Submit Article | Articles Home | Search Articles |

Diff Between DataGrid and GridView

 Posted on: 9/17/2008 11:20:35 PM by Majith | Views: 5523 | Category: ADO.NET | Level: Intermediate | Print Article
Im going to expail the various difference between GridView and the DataGrid controls and their different logics.

.NET Training Videos!
Buy online comprehensive training video pack just for $35.00 only, see what's inside it.

Introduction

The GridView and the DataGrid controls have a different logics.


There is a lot of differnce compatibility between DataGrid and GridView Codes

GridView can bulid pages on mobile devices

DataGrid in  1.x doesn't supports the themes however in 2.0 it perform themes.

The DataGrid in version 2.0 can also render adaptively,

GridView supports the classic bindingbased on the DataSource property.

GridView provides the option for paging ,sorting in easy click of a button however datagrid
required some coding

Grid View Features

· Richer design-time capabilities.
· Improved data source binding capabilities.
· Automatic handling of sorting, paging, updates, and deletes.
· Additional column types and design-time column operations.
· A Customized pager user interface (UI) with the PagerTemplate property.

· Different custom-paging support.
· Different event models.

For Example how the paging index differs
DataGrid

HTML

 <asp:DataGrid ID="DataGrid1" runat="server" OnPageIndexChanged="DataGrid1_PageIndexChanged"
 AllowPaging="true" PageSize="5" OnSelectedIndexChanged="d1_SelectedIndexChanged">
 </asp:DataGrid>  




Codebehind


protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
      DataGrid1.CurrentPageIndex =  e.NewPageIndex 
      BindGrid();// Grid binding method
    }

GridView

 <asp:GridView ID="GridView1" runat="server" OnPageIndexChanging="DataGrid1_PageIndexChanging"
  AllowPaging="true" PageSize="5" OnSelectedIndexChanged="d1_SelectedIndexChanged">
  </asp:GridView>  

Codebehind

protected void GridView1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {
      GridView1.PageIndex =  e.NewPageIndex 
      BindGrid();// Grid binding method
    }   


It allows for the mix both data bound and unbound, virtual columns in the GridView.

It has a special virtual mode allowing for the display of more than 100.000 rows without
a huge performance hit.

Individual columns, rows, cells or an entire data source can easily be styled.

private void InsertDataGridColumn()
{
DataSet dataset = new DataSet();
DataGridTableStyle TStyle = new DataGridTableStyle();
DataTable table = dataset.Tables["Student"];
TStyle .GridColumnStyles[0].MappingName ="Stid"
TStyle .GridColumnStyles[0].HeaderText = "Student ID";
TStyle .GridColumnStyles[0].Width = 150;
DataGrid1.TableStyles.Add(TStyle );
}

The above example is used for DataGrid TableStyle.

DataGridView control designing operations are done through the IDE design layout window via drag and drop.

We can extend the DataGridView control in a number of ways to build custom behaviors
into your applications .

Conclusion

The above article describes the simple diff logics between GridView and DataGrid Controls.

Cheers Coding!



 


If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Interesting?   Share and Bookmark this kick it on DotNetKicks.com


About Majith Basha

Experience:0 year(s)
Home page:
Member since:Friday, July 18, 2008
Level:Starter
Status: [Member]
Biography:
 Latest post(s) from Majith

   ◘ Checking Existing Records Using Array of Data Rows posted on 4/13/2009 5:41:54 AM
   ◘ Finding Curosr Position Using JavaScript and Drag and Drop from WebControls posted on 2/24/2009 10:24:45 PM
   ◘ Reading Selected Element from XML using ASP.NET, C# posted on 11/25/2008 8:23:38 AM
   ◘ Java Script GridView ClientSide Validation posted on 9/30/2008 12:22:12 AM
   ◘ Diff Between DataGrid and GridView posted on 9/17/2008 11:20:35 PM


Submit Article

About Us | The Team | Advertise | Contact Us | Feedback | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found copied contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
All rights reserved to DotNetFunda.Com. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
(Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher)