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

[Solved] How to Save the RadGridView Edited Records

4 Answers 179 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
satish
Top achievements
Rank 1
satish asked on 05 Aug 2009, 01:05 PM
Hi,
 
 I am working on RadGridView. I am populating the grid data with WCF service. 
 Now my problem is I want to update the edited records of the RadGridView. I am not getting the edited records from the grid.
 Whenever user clicks on Save button I have to retrive the edited records from the grid. 
 
 Can anybody please tell me how to get the edited records from the grid.
 Can anybody please help me on this. If possible could you please send me some sample on that.
 
 Inadvance thanks for your time.
 
Regards
Satish
 

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 07 Aug 2009, 10:43 AM
Hi satish,

You can attach to the RowEditEnded event and cache all edited data items like this:

<UserControl x:Class="TicketID_226294_RowDetailsCustom.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"  
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> 
    <Grid> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="Auto"/> 
            <RowDefinition Height="Auto"/> 
        </Grid.RowDefinitions> 
        <Button Margin="10"  
                Width="100"  
                Height="24"  
                HorizontalAlignment="Left"  
                Content="Save"  
                Click="OnSave"/> 
        <telerik:RadGridView Name="clubsGrid" 
                             Grid.Row="1" 
                             RowEditEnded="RadGridView_RowEditEnded" 
                             ValidationMode="Row"> 
        </telerik:RadGridView> 
    </Grid> 
</UserControl> 
 

using System.Collections.Generic; 
using System.Windows; 
using System.Windows.Controls; 
using Telerik.Windows.Controls; 
using Telerik.Windows.Data; 
 
namespace TicketID_226294_RowDetailsCustom 
{ 
    public partial class MainPage : UserControl 
    { 
        public MainPage() 
        { 
            this.InitializeComponent(); 
            this.clubsGrid.ItemsSource = Club.GetClubs(); 
        } 
 
        private List<Club> editedClubs = new List<Club>(); 
 
        private void RadGridView_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) 
        { 
            var dataRecord = e.Row.Record as DataRecord; 
            if (dataRecord != null) 
            { 
                var club = dataRecord.Data as Club; 
                if (club != null && !this.editedClubs.Contains(club)) 
                { 
                    this.editedClubs.Add(club); 
                } 
            } 
        } 
 
        private void OnSave(object sender, RoutedEventArgs e) 
        { 
            foreach (Club editedClub in this.editedClubs) 
            { 
                MessageBox.Show(editedClub.Name); 
            } 
        } 
    } 
} 

I have attached the sample project that the above code snippets are from. I hope it helps.

Greetings,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
satish
Top achievements
Rank 1
answered on 10 Aug 2009, 12:59 PM
Hi ROSS,

   Thanks a lot for the response.
   It's helped me a lot.

   I am facing onemore problem with the RadTimePicker Control. It's like I am unable to set the Time to the control dynamically. I am getting value from db and when i try to set the value like this.


Public Sub SetComboValues(ByVal sBeginTime As String, ByVal sEndTime As String, ByVal iAdminDuration As Integer)  
 
        Dim tspBegin As TimeSpan  
        tspBegin = TimeSpan.Parse(sBeginTime)  
        timePicVisitBegin.SelectedTime = tspBegin  
 
 
End Sub 

I AM GETTING THE FOLLOWING ERROR

Input string was not in a correct format.


Can you please kindly help me on this.

Regards
Satish
0
Valeri Hristov
Telerik team
answered on 12 Aug 2009, 01:12 PM
Hi satish,

I guess that the value in the database contains some illegal symbols, which prevent the TimeSpan.Parse() method from correctly parsing it. You could try to set a breakpoint at the following line:
tspBegin = TimeSpan.Parse(sBeginTime)  

and see what's the value of the sBeginTime variable and then determine what's wrong and fix the problem.

Sincerely yours,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
pat
Top achievements
Rank 1
answered on 14 Aug 2011, 09:03 PM
This example does not work in SL4. Is there an update?
Tags
GridView
Asked by
satish
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
satish
Top achievements
Rank 1
Valeri Hristov
Telerik team
pat
Top achievements
Rank 1
Share this question
or