Grid values are not updated on save

2 posts, 0 answers
  1. Galina
    Galina avatar
    6 posts
    Member since:
    May 2018

    Posted 22 Jun 2018 Link to this post

    I use a very simple grid with data source and AllowAutomaticUpdates="True"  and AllowAutomaticInserts="True"

    Insert works perfectly, but for update, after I choose new date and comment and click update, the old values are sent to stored procedure(logged them from stored procedure to make sure). What am I missing?

     

    <telerik:RadGrid ID="RadGridTimeSlots" runat="server" AllowAutomaticDeletes="true" AllowAutomaticInserts="True"
                GroupPanelPosition="Top" ResolvedRenderMode="Classic" AllowAutomaticUpdates="True" DataSourceID="dsTimeSlots" OnItemUpdated="RadGridTimeSlots_ItemUpdated" OnItemInserted="RadGridTimeSlots_ItemInserted">
                <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="False" DataKeyNames="ID,DateFrom,DateTo,comment" EditMode="InPlace" DataSourceID="dsTimeSlots">
                    <Columns>
                        <telerik:GridDateTimeColumn DataField="DateFrom" HeaderText="Date From" UniqueName="DateFrom" PickerType="DateTimePicker" />
                        <telerik:GridDateTimeColumn DataField="DateTo" HeaderText="Date To" UniqueName="DateTo" PickerType="DateTimePicker" />
                        <telerik:GridBoundColumn DataField="comment" HeaderText="Comment" UniqueName="comment"></telerik:GridBoundColumn>
                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                        </telerik:GridEditCommandColumn>
                        <telerik:GridButtonColumn CommandName="Delete" ConfirmText="Do you want to delete this time slot?" ButtonType="ImageButton" HeaderText="Delete?" ConfirmDialogType="RadWindow" UniqueName="btnDelete">
                            <ItemStyle VerticalAlign="Top" />
                        </telerik:GridButtonColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        <asp:HiddenField ID="hMyAccountName" runat="server" />
            <asp:SqlDataSource ID="dsTimeSlots" runat="server"
                ConnectionString="<%$ ConnectionStrings:PPMTESTConnectionString %>"
                SelectCommand="execute SelectOutOfOfficeSlots @accountName"
                InsertCommand="execute InsertOutOfOfficeSlot @accountName,@DateFrom,@DateTo,@comment"
                UpdateCommand="execute UpdateOutOfOfficeSlot @ID,@accountName, @DateFrom,@DateTo, @comment">
                <SelectParameters>
                    <asp:ControlParameter ControlID="hMyAccountName" Name="accountName" PropertyName="Value" />
                </SelectParameters>
                <InsertParameters>
                    <asp:ControlParameter ControlID="hMyAccountName" Name="accountName" PropertyName="Value" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:ControlParameter ControlID="hMyAccountName" Name="accountName" PropertyName="Value" />
                </UpdateParameters>
            </asp:SqlDataSource>

     

     

     

    Partial Class MyOutOfOffice
        Inherits System.Web.UI.Page
        Dim myAccountName As String

        Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
            myAccountName = Session("DomainAccount")
            hMyAccountName.Value = myAccountName
            Label2.Text = ""
        End Sub


        Protected Sub chkOutOdOffice_CheckedChanged(sender As Object, e As EventArgs)

        End Sub
        Protected Sub RadGridTimeSlots_ItemUpdated(sender As Object, e As GridUpdatedEventArgs)
            If (Not (e.Exception Is Nothing)) Then

                e.ExceptionHandled = True
                Label2.Text = Label2.Text & e.Exception.Message & "<BR/>"
            End If
        End Sub
        Protected Sub RadGridTimeSlots_ItemInserted(sender As Object, e As GridInsertedEventArgs)
            If (Not (e.Exception Is Nothing)) Then

                e.ExceptionHandled = True
                Label2.Text = Label2.Text & e.Exception.Message & "<BR/>"
            End If
        End Sub
    End Class

  2. Galina
    Galina avatar
    6 posts
    Member since:
    May 2018

    Posted 22 Jun 2018 in reply to Galina Link to this post

    Never mind, I figured it out. I only should have ID in keys, not the rest
Back to Top