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

Grid values are not updated on save

1 Answer 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Galina
Top achievements
Rank 1
Galina asked on 22 Jun 2018, 07:02 PM

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

1 Answer, 1 is accepted

Sort by
0
Galina
Top achievements
Rank 1
answered on 22 Jun 2018, 07:35 PM
Never mind, I figured it out. I only should have ID in keys, not the rest
Tags
Grid
Asked by
Galina
Top achievements
Rank 1
Answers by
Galina
Top achievements
Rank 1
Share this question
or