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

Need DataKeyValues on Add or Edit Mode

3 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
dbernett
Top achievements
Rank 2
dbernett asked on 08 Jun 2011, 03:22 PM
I need to retrive the DataKeyValues in my ItemDataBound when someone clicks Add or Update.  Can you tell me how to do that?

 

 

Protected Sub grdMSC_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
    
      If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then
            
          If (e.Item.OwnerTableView.IsItemInserted) Then
               'Does NOT work always returns -1
               lblMessage1.Text = Me.grdMSC.MasterTableView.DataKeyValues(e.Item.RowIndex)("Category_ID").ToString
          Else
           
          End If
            
      End If
        
  End Sub

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 08 Jun 2011, 04:33 PM
Hi David,

Please refer to the code snippet in the help article below for more information about how to achieve your goal:
http://www.telerik.com/help/aspnet-ajax/grid-insert-update-delete-at-database-level.html

All the best,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
dbernett
Top achievements
Rank 2
answered on 08 Jun 2011, 04:42 PM
Thanks but that link did not answer my question.  There are NO exampes for retrieving the dataKeys in the ItemDataBound.

I discovered the solution myself.  It is.

Protected Sub grdMSC_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
      If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then
            
          Dim CategoryID As String = grdMSC.MasterTableView.DataKeyValues(e.Item.OwnerTableView.ParentItem.ItemIndex)("Category_ID").ToString
            
      End If
    
  End Sub
0
Accepted
Pavlina
Telerik team
answered on 08 Jun 2011, 04:52 PM
Hello David,

I am glad that you were able to resolve this issue on your own. Have a good day!

Regards,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
dbernett
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
dbernett
Top achievements
Rank 2
Share this question
or