This is a migrated thread and some comments may be shown as answers.

Cannot retrieve the 2nd page DataKeyName item inde

2 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nanthakumar thangavel
Top achievements
Rank 1
nanthakumar thangavel asked on 08 Jun 2011, 04:37 PM
Hi,

 if I ll bind 500 rows to rad-grid with set property allowpaging is true ,after that I pass the 2nd pageDataKeyName value as a parameter.  but I can not retrieve the 2nd page DataKeyName item index.

what can i do for this problem?

this is my  code

Private Sub GRD_NewsList_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GRD_NewsList.PreRender
        If Not Page.IsPostBack Then
            Dim val As String = GetNumeric(Request("NewsId"))
            If val = 0 Then
                GRD_NewsList.MasterTableView.IsItemInserted = True
            Else
                For Each Items As GridDataItem In GRD_NewsList.MasterTableView.Items
  
                    If GetNumeric(Items.GetDataKeyValue("NewsId")) = val Then
                        Items.Edit = True
                        Exit For
                    End If
                Next
            End If
            GRD_NewsList.Rebind()
        End If
    End Sub

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Jun 2011, 08:38 AM
Hello NanthaKumar,

One option is you can temporarily disabling the paging, rebind the grid and retrieve all the items. After getting all the item, you can re-enable the paging for grid.

C#:
protected void GRD_NewsList_PreRender(object sender, EventArgs e)
   {
       GRD_NewsList.AllowPaging = false;
       GRD_NewsList.Rebind();
       foreach (GridDataItem item in GRD_NewsList.Items)
       {
           string key = item.GetDataKeyValue("NewsId").ToString();
       }
       GRD_NewsList.AllowPaging = true;
       GRD_NewsList.Rebind();
   }

-Shinu.
0
nanthakumar thangavel
Top achievements
Rank 1
answered on 10 Jun 2011, 03:22 PM
Hi 
but  I want  to open the 2nd page index item in edit mode by default .

 what can i do for this ?

This is my code :

Dim val As String = GetNumeric(Request("NewsId"))
If val > 0 Then
    GRD_NewsList.MasterTableView.AllowPaging = False
    GRD_NewsList.Rebind()
    For Each Items As GridDataItem In GRD_NewsList.MasterTableView.Items
        If GetNumeric(Items.GetDataKeyValue("NewsId")) = val Then
            Items.Edit = True
            Exit For
        End If
    Next
 
    GRD_NewsList.MasterTableView.AllowPaging = True
    GRD_NewsList.Rebind()
End If

Tags
Grid
Asked by
nanthakumar thangavel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
nanthakumar thangavel
Top achievements
Rank 1
Share this question
or