I am coming with very intresting topic. Currently i am working on conversion project. I am converting dotnet1.1 project to dot net 3.5. Microsoft provide the tool to convert the application. But it is not converting Datagrid to GridView. So i am doing manually. So here i am discussion some point to consider when we convert grids.
Currently i am writing down only the steps and very soon i will publish the code also. till you can ask th ecode via email id : tomksaini@gmail.com
Changes on .aspx file
1. In Datagrid we have tag "TemplateColumn", but in GridView we have "TemplateField". So when convert the datagrid to Gridview, take care ot these things. We need to change manually
Example :
DataGrid :
2. In DataGrid we have tag "ItemStyle" , but in GridView we have "RowStyle"
Example :
DataGrid :
It depends how many functionality you have implemented with grid. I am covering most common here,
1. ItemDataBound /RowDataBound:
In datagrid, "ItemDataBound" fire when we bind the grid. corresponding to this , we have "RowDataBound" event in Gridview.
For example "
DataGrid :
MyDataGrid_ItemDataBound(ByVal Sender As Object, ByVal E As DataGridItemEventArgs)
GridView :
MyGridNew_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles MyGridNew.RowDataBound
In Datagrid, we have many item type and accordingly we use them. while converting just replace
following
e.Item.ItemType = ListItemType.EditItem
E.Item.ItemType = ListItemType.AlternatingItem
with
e.Row.RowType = DataControlRowType.DataRow.
(EditItem, AlternatingItem not supported by GridView)
2. ItemCreated/RowCreated:
In datagrid, "ItemCreated" fire when item created in grid. corresponding to this , we have "RowCreated" event in Gridview.
For Example:
Datagrid :
Sub MyDataGrid_ItemCreated(ByVal Sender As Object, ByVal e As DataGridItemEventArgs)
GridView :
Sub MyGridNew_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles MyGridNew.RowCreated
* need to take care of "editItem" and "AlternatingItem"
3. Update/RowUpdating :
In DataGrid, we have we have one update event which one fire when updation happen. In Gridview we have we event : one is "Updating" and another one is "Updated".
(a) Updating : just before the actual updation and we can also cancel the updation at that time also.
(b) Updated: just after the updation happen.
So replace DataGrid's Update event with GridView's Updating.
4. CurrentPageIndex/PageIndex:
In datagrid we have one property "CurrentPageIndex" but in gridView we have "PageIndex" property to set/get the page index.
I have covered most common event and changes. I hope it will help you. You can contact me tomksaini@gmail.com .
No comments:
Post a Comment