Serial No
-
I am Trying to Display Serial No and Paging in datagrid. ----------------Bind Function------- Private Function Bindxx() dgxx.DataSource = objxx.Getxx() dgxx.DataBind() Private i As Integer = 0 Private Item As DataGridItem For Each Item In dgxx.items i += 1 Item.Cells(0).Text = i Next End Function ----------------------------------Paging---------- Private Sub dgxx_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgStudents.PageIndexChanged dgStudents.CurrentPageIndex = e.NewPageIndex BindStudents() End Sub ------------------------------ If I set 5 rows Page size, For the First page It will display Perfect Serial No. Now When I click 2nd Page I will dispaly same serial No 1,2,3,4,5 but I want 6,7,8 etc. Mkanchha
-
I am Trying to Display Serial No and Paging in datagrid. ----------------Bind Function------- Private Function Bindxx() dgxx.DataSource = objxx.Getxx() dgxx.DataBind() Private i As Integer = 0 Private Item As DataGridItem For Each Item In dgxx.items i += 1 Item.Cells(0).Text = i Next End Function ----------------------------------Paging---------- Private Sub dgxx_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgStudents.PageIndexChanged dgStudents.CurrentPageIndex = e.NewPageIndex BindStudents() End Sub ------------------------------ If I set 5 rows Page size, For the First page It will display Perfect Serial No. Now When I click 2nd Page I will dispaly same serial No 1,2,3,4,5 but I want 6,7,8 etc. Mkanchha
-
Use this formula for the serial number column of the DataGrid (PageIndex * pagesize) + ItemIndex +1
-
I am Trying to Display Serial No and Paging in datagrid. ----------------Bind Function------- Private Function Bindxx() dgxx.DataSource = objxx.Getxx() dgxx.DataBind() Private i As Integer = 0 Private Item As DataGridItem For Each Item In dgxx.items i += 1 Item.Cells(0).Text = i Next End Function ----------------------------------Paging---------- Private Sub dgxx_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgStudents.PageIndexChanged dgStudents.CurrentPageIndex = e.NewPageIndex BindStudents() End Sub ------------------------------ If I set 5 rows Page size, For the First page It will display Perfect Serial No. Now When I click 2nd Page I will dispaly same serial No 1,2,3,4,5 but I want 6,7,8 etc. Mkanchha
Hi, There is an event for the datagrid called ItemDataBound. Suppose your datagrid name is dgrd1. Write the following code under that event. public void dgrd1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if(e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer) { e.Item.Cells[0].Text=Convert.ToString(e.Item.DataSetIndex + 1); } }
Meeram395
-
Hi, There is an event for the datagrid called ItemDataBound. Suppose your datagrid name is dgrd1. Write the following code under that event. public void dgrd1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if(e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer) { e.Item.Cells[0].Text=Convert.ToString(e.Item.DataSetIndex + 1); } }
Meeram395
-
Hi, There is an event for the datagrid called ItemDataBound. Suppose your datagrid name is dgrd1. Write the following code under that event. public void dgrd1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if(e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer) { e.Item.Cells[0].Text=Convert.ToString(e.Item.DataSetIndex + 1); } }
Meeram395
Thank you...