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

[Solved] RIA adding new row

4 Answers 177 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.
Maxim
Top achievements
Rank 1
Maxim asked on 19 Aug 2009, 08:18 PM
For some reason I an unable to add new record using insert key. The grid refuses to handle it for some reason. I can see and edit it but not insert new record. Can some one advise me on what am I doing wrong.
PS: I am using RIA Services.
Thanks.

                    <radGrid:RadGridView x:Name="radGrid" 
                                         Margin="10,10,10,10" 
                                         AutoGenerateColumns="False"
                        <radGrid:RadGridView.Columns> 
                            <radGrid:GridViewDataColumn Header="Administrator" DataMemberPath="Administrator"/> 
                            <radGrid:GridViewDataColumn Header="Windows account" DataMemberPath="WindowsAccount"/> 
                        </radGrid:RadGridView.Columns> 
                    </radGrid:RadGridView> 

    public partial class AdministratorList : Page 
    { 
        OperationsDomainContext _context = new OperationsDomainContext(); 
 
        public AdministratorList() 
        { 
            InitializeComponent(); 
            radGrid.ItemsSource = _context.ReportAdministartors; 
            _context.Load(_context.GetReportAdministartorsQuery()); 
        } 
 
        // Executes when the user navigates to this page. 
        protected override void OnNavigatedTo(NavigationEventArgs e) 
        { 
        } 
    } 
 

4 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 20 Aug 2009, 10:25 AM
Hello Maxim,

The grid is relaying on the fact that your object has a default constructor and use it to create the new object. If your object did not have a parameterless constructor you should use the GridView's event AddingNewDataItem and set the NewObject property to your newly created object.

You can also look at our online example that is using RIA services and DomainDataSource here.

Kind regards,
Stefan Dobrev
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
Maxim
Top achievements
Rank 1
answered on 20 Aug 2009, 02:06 PM
Thanks for the info, however grid wont even fire a AddingNewDataItem event for some reason.
FYI: The entity named ReportAdministrator has default constructor and I am not using DomainDataSource. Can it be done without using DomainDataSource?
0
Kenneth Jamieson
Top achievements
Rank 1
answered on 23 Aug 2009, 01:02 AM
Thanks for the tip on the adding row bug - it just saved me a few hours :)

Now - whats the best way to commit that change?
0
Stefan Dobrev
Telerik team
answered on 25 Aug 2009, 02:26 PM
Hello Kenneth,

The best way to commit changes is to have a save button somewhere on the screen. When the button is clicked you can call the SubmitChanges() method on the DomainContext class. This will submit all your changes you have made.

For further reading you can look out at the RIA Services Overview document which illustrates all the capabilities of the platform.

Sincerely yours,
Stefan Dobrev
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.
Tags
GridView
Asked by
Maxim
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Maxim
Top achievements
Rank 1
Kenneth Jamieson
Top achievements
Rank 1
Share this question
or