Add new row with timestamp problem

3 posts, 0 answers
  1. Babu Mannaravalappil
    Babu Mannaravalappil avatar
    15 posts
    Member since:
    Oct 2009

    Posted 24 Jan 2011 Link to this post

    Hi,

    I have a RadGridView, a RadDomainDataSource, a RIA DomainService and a .NET EntityFramework Model from my SQL database.  My grid works fine; it fetches the data and displays it in the grid as expected.  The underlying table for this Entity contains a non-nullable timestamp field by the name "Modified".  I don't want to show this field in the grid and so I did not create a grid column for it.  When I press the Insert key, as expected, a new blank row is inserted in the grid.  So far, so good.  But after filling the column values, and I press tab key to lose focus from the row, I get an error saying "The 'Modified' field is required".  How can I get rid of this error.  In other words, how would I go about validating the data to elimiate the error message.  Here is my XAML for the page.  Please advise.

    <UserControl
        x:Class="Library.Views.Contributors"
        mc:Ignorable="d"
        d:DesignHeight="500"
        d:DesignWidth="700"
        xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
        xmlns:my="clr-namespace:Library.Web.Model"
        xmlns:vm="clr-namespace:Library.ViewModels"
        xmlns:ds="clr-namespace:Library.Web.Model">
        <UserControl.Resources>
            <vm:ContributorListViewModel
                x:Key="ContributorsViewModel"
                xmlns:vm="clr-namespace:Library.ViewModels" />
        </UserControl.Resources>
      
        <Grid
            x:Name="LayoutRoot"
            Background="White">
            <Grid.ColumnDefinitions>
                <ColumnDefinition
                    Width="0.731*" />
                <ColumnDefinition
                    Width="0.269*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition
                    Height="0.8*" />
                <RowDefinition
                    Height="0.2*" />
            </Grid.RowDefinitions>
            <telerik:RadDomainDataSource
                x:Name="ContributorDS"
                QueryName="GetContributors"
                AutoLoad="True"
                PageSize="10"
                >
                <telerik:RadDomainDataSource.DomainContext>
                    <ds:LibraryDataDomainContext />
                </telerik:RadDomainDataSource.DomainContext>
            </telerik:RadDomainDataSource>
            <telerik:RadBusyIndicator
                IsBusy="{Binding IsBusy, ElementName=ContributorDS}">
                <telerik:RadGridView
                    Name="rgContributors"
                    HorizontalAlignment="Stretch"
                    ItemsSource="{Binding DataView, ElementName=ContributorDS}"
                    IsBusy="{Binding IsBusy, ElementName=ContributorDS}" AutoGenerateColumns="False">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn
                            x:Name="PKId"
                            DataMemberBinding="{Binding PKId}"
                            Header="PKId"
                            UniqueName="PKId"
                            IsVisible="False" />
                        <telerik:GridViewDataColumn
                            x:Name="Name"
                            DataMemberBinding="{Binding Name}"
                            UniqueName="Name"
                            Width="3*"
                            Header="Name" />
                        <telerik:GridViewDataColumn
                            x:Name="Description"
                            DataMemberBinding="{Binding Description}"
                            UniqueName="Description"
                            Width="6*"
                            Header="Description" />
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>
            </telerik:RadBusyIndicator>
        </Grid>
    </UserControl>

    Thanks.

    Babu.
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 31 Jan 2011 Link to this post

    Hello Babu Mannaravalappil,

    You should handle the AddingNewDataItem event of RadGridView and set the timestamp property of the new object. You can find a sample project here.

    Kind regards,
    Veselin Vasilev
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. PMoransais
    PMoransais avatar
    17 posts
    Member since:
    Mar 2007

    Posted 07 Oct 2011 Link to this post

    The suggestion to provide a value for the timestamp field during row creation does not sound right: in SQLServer, fields of type timestamp are calculated by the database (Computed in Entity Framework). 

    The only solution I can think of is to not include the field in the data set.That could present a problem in some scenarios

    Thanks

Back to Top