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

Return All Data From Grid

1 Answer 32 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Terry asked on 26 Jun 2012, 08:36 PM
<telerik:RadGrid ID="RadGridItemSizes" runat="server" AllowPaging="false" AllowSorting="True" GridLines="None" Skin="Windows7" Width="95%">                                                        
<MasterTableView AutoGenerateColumns="false" EditMode="InPlace" >
 No Sizes Found
<telerik:GridBoundColumn    DataField="IT_SizePk"   UniqueName="SizePk" Visible="false" />
<telerik:GridCheckBoxColumn DataField="Checked"     HeaderText="Select"         HeaderStyle-Width="20px"    UniqueName="Checked"/>
<telerik:GridBoundColumn    DataField="Size"        HeaderText="Size"           HeaderStyle-Width="40px"    ReadOnly="true"/>                                                               
<telerik:GridNumericColumn  DataField="SizePremium" HeaderText="Size Premium"   HeaderStyle-Width="100px"   UniqueName="SizePremium" DecimalDigits="2" DataFormatString="{0:f3}" />

I have the above Grid. And the following Code being used for this grid

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
               'Put In Edit Mode
                Dim i As Integer
                For i = 0 To RadGridItemSizes.PageSize - 1
                Next i
            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
End Sub

Private Sub SaveDataSpecificationTab()
                Dim Sizes() As Guid = {}
                Dim SizesPrices() As Double = {}
               For Each DataItem As GridEditableItem In RadGridItemSizes.EditItems
                   Dim CheckBox As CheckBox = DirectCast(DataItem("Checked").Controls(0), CheckBox)
                   Dim txtbox As TextBox = DirectCast(DataItem("SizePk").Controls(0), TextBox)
                   Dim SizePk As String = txtbox.Text
                   txtbox = DirectCast(DataItem("SizePk").Controls(0), TextBox)
                   Dim SizePremium As String = txtbox.Text
                   If CheckBox.Checked Then
                       ReDim Preserve Sizes(Sizes.Length)
                       ReDim Preserve SizesPrices(SizesPrices.Length)
                       Sizes(UBound(Sizes)) = New Guid(SizePk)
                       SizesPrices(UBound(SizesPrices)) = SizePremium
                   End If
End Sub

Private Sub RadGridItemSizes_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridItemSizes.ItemCreated
           If (Not Page.IsPostBack AndAlso TypeOf e.Item Is GridEditableItem) Then
               e.Item.Edit = True
           End If
       End Sub
       Private Sub RadGridItemSizes_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGridItemSizes.NeedDataSource
           Dim Item As ConvergenceDataAccess.Items = New ConvergenceDataAccess.Items(Me.ConnectString)
           RadGridItemSizes.DataSource = Item.GetDataTable_ItemSizesPremium(New Guid(ItemPk.Value))
       End Sub

This page is also using the RadAjaxManager.

I haven't been able to pull the data from the grid to save using the SaveDataSpecificationTab()  Sub - being called by a button.

I've tried pretty much all of the suggestions I have found here and through google.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 28 Jun 2012, 07:30 AM
Hello Tarus,

Just use the ExtractValues method of the GridEditableItem object. It accepts a Hashtable as a parameter and populates it with the values in the edit form fields.

Hope it helps.

All the best,
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question