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

RadGrid editform editedItem.DataItem object

1 Answer 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dimitrios
Top achievements
Rank 1
Dimitrios asked on 01 Sep 2014, 07:37 AM
I am using WebUserControls (ascx files) for editing a rad grid in two cases (Product Items and Order detail rows)

I would appreciate if someone can give me an idea on why in the fisrt case the Public Property DataItem() contains a DataRowView object, while in the second case the Public Property DataItem() contains a DynamicClass1 type with the values of the row fields {field1 = value1, field2 = value2...} (as exaclty works in the Telerik example)

In the DataBinding event...

in the first case I am accessing the values of the edited row as:  CType(editedItem.DataItem, DataRowView).Item(#) (!!)
in the second case I am accessing the values of the edited row as:  editedItem.DataItem.field1  (as exaclty works in the Telerik example)

I show you some relative code:

-----------------------
first case
-----------------------
ascx.vb
Imports System.Data.SqlClient
Imports System
Imports System.Data
Imports System.Collections
Imports System.Web.UI
Imports Telerik.Web.UI

Namespace EditFormItemDetails

  Class ItemDetails
    Inherits System.Web.UI.UserControl

    Private _dataItem As Object = Nothing


#Region "Web Form Designer generated code"

    Protected Overrides Sub OnInit(ByVal e As EventArgs)
      InitializeComponent()
      MyBase.OnInit(e)
    End Sub

    Private Sub InitializeComponent()
      AddHandler DataBinding, AddressOf Me.ItemDetails_DataBinding
    End Sub

#End Region

    Protected Sub Page_Load(sender As Object, e As EventArgs)
    End Sub

    Public Property DataItem() As Object
      Get
        Return Me._dataItem
      End Get
      Set(ByVal value As Object)
        Me._dataItem = value
      End Set
    End Property

ascx
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ItemDetails.ascx.vb"
  Inherits="EditFormItemDetails.ItemDetails" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

aspx

<telerik:RadGrid ID="grdItems"
....
    <EditFormSettings UserControlName="ItemDetails.ascx"
              EditFormType="WebUserControl">
              <EditColumn ButtonType="ImageButton"/>   
              <PopUpSettings Width="1228px" Modal="true"/>
    </EditFormSettings>

-----------------------
second case
-----------------------
ascx.vb
Imports System.Data.SqlClient
Imports System
Imports System.Data
Imports System.Collections
Imports System.Web.UI
Imports Telerik.Web.UI

Namespace EditFormOrderDetails

  Class OrderDetails
    Inherits System.Web.UI.UserControl

    Private _dataItem As Object = Nothing


#Region "Web Form Designer generated code"

    Protected Overrides Sub OnInit(ByVal e As EventArgs)
      InitializeComponent()
      MyBase.OnInit(e)
    End Sub

    Private Sub InitializeComponent()
      AddHandler DataBinding, AddressOf Me.OrderDetails_DataBinding
    End Sub

#End Region

    Protected Sub Page_Load(sender As Object, e As EventArgs)
    End Sub

    Public Property DataItem() As Object
      Get
        Return Me._dataItem
      End Get
      Set(ByVal value As Object)
        Me._dataItem = value
      End Set
    End Property

ascx
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="OrderDetails.ascx.vb"
  Inherits="EditFormOrderDetails.OrderDetails" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

aspx

<telerik:RadGrid ID="grdItems"
....
    <EditFormSettings UserControlName="OrderDetails.ascx"
              EditFormType="WebUserControl">
              <EditColumn ButtonType="ImageButton"/>   
              <PopUpSettings Width="800px" Modal="true"/>
    </EditFormSettings>


I would appreciate if someone understands the reason of the dataitem difference.

(I am not really sure which other part of my code is relative. Please ask me to post whatever is useful.)

Thanks








1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 04 Sep 2014, 05:12 PM
Hi Dimitrios,

Try using the DataBinder.Eval method and it should work in all cases:
http://msdn.microsoft.com/en-us/library/4hx47hfe%28v=vs.110%29.aspx

Looking forward to your reply.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Dimitrios
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or