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

Grid / Automatic Operations

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gullo
Top achievements
Rank 1
Gullo asked on 10 Feb 2012, 01:32 PM

Hi together,

I have a question about the RadGrid. I have now created a RadGrid with a Edit, Delete and Add new Record Button. The Edit Mask shows fine, but if I Edit a record it dosn't update it. When I debug I see that it doesnt't run my Update Method in my Code.

Below my apsx and my methods.

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="radGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="radGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadioButton1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadioButton2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadioButton2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadioButton1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="CheckBox1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
        Width="75px" Transparency="25">
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
            style="border: 0;" />
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="radGrid1" AutoGenerateEditColumn="True" DataSourceID="objectDataSource1"
        runat="server" GridLines="None" Skin="Office2010Blue">
        <MasterTableView AllowAutomaticUpdates="True" AllowAutomaticInserts="True" CommandItemDisplay="Top"
            DataSourceID="ObjectDataSource1">
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                    <ItemStyle CssClass="MyImageButton" />
                </telerik:GridEditCommandColumn>
               <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                    UniqueName="DeleteColumn">
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                </telerik:GridButtonColumn>
            </Columns>
            <EditFormSettings ColumnNumber="2" CaptionDataField="Address" CaptionFormatString="Edit properties of Address Case Relations">
                <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" Width="100%" />
                <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit"/>           
                 <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" Width="100%" />
                <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                </EditColumn>
                <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                <PopUpSettings ScrollBars="None" />
            </EditFormSettings>
             
            <RowIndicatorColumn Visible="False">
                <HeaderStyle Width="20px" />
            </RowIndicatorColumn>
            <ExpandCollapseColumn Resizable="False" Visible="False">
                <HeaderStyle Width="20px" />
            </ExpandCollapseColumn>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:ObjectDataSource ID="objectDataSource1" TypeName="ESTV.A3.Logic.AddressCaseRelationBll" SelectMethod="Select" UpdateMethod="Update" InsertMethod="Insert" DeleteMethod="Delete" runat="server"
        OldValuesParameterFormatString="original_{0}">
        <SelectParameters>
            <asp:QueryStringParameter Name="addressId" Type="String" Direction="Input" QueryStringField="id">
            </asp:QueryStringParameter>
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="id" Type="String" />
            <asp:Parameter Name="NotificationDate" Type="DateTime" />
            <asp:Parameter Name="NoticeOfReceipt" Type="Boolean" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="id" Type="String" />
            <asp:Parameter Name="NotificationDate" Type="DateTime" />
            <asp:Parameter Name="NoticeOfReceipt" Type="Boolean" />
        </InsertParameters>
        <DeleteParameters>
            <asp:Parameter Name="id" Type="String"/>
        </DeleteParameters>
    </asp:ObjectDataSource>

And here my Code

public List<AddressCaseRelation> Select(string addressId)
       {
           ////TODO: validation and error handling
           Guid guidId = new Guid(addressId);
           return entityDao.GetByAddressId(guidId);
       }
 
       public void Update(string id, bool noticeOfReceipt, DateTime notificationDate)
       {
           Guid guidId = new Guid(id);
           AddressCaseRelation addressCaseRelation = entityDao.GetById(guidId);
 
           addressCaseRelation.NoticeOfReceipt = noticeOfReceipt;
           addressCaseRelation.NotificationDate = notificationDate;
            
           entityDao.Update(addressCaseRelation);
           entityDao.CommitChanges();
       }
 
       public void Insert(string id, bool noticeOfReceipt, DateTime notificationDate)
       {
           Guid guidId = new Guid(id);
           AddressCaseRelation addressCaseRelation = entityDao.GetById(guidId);
 
           addressCaseRelation.NoticeOfReceipt = noticeOfReceipt;
           addressCaseRelation.NotificationDate = notificationDate;
 
           entityDao.Update(addressCaseRelation);
           entityDao.CommitChanges();
       }
 
       public void Delete(string id)
       {
           Guid guidId = new Guid(id);
           AddressCaseRelation addressCaseRelation = entityDao.GetById(guidId);
           entityDao.Delete(addressCaseRelation);
           entityDao.CommitChanges();
       }

I have also the same problem if i click the Add new Record Button, the form doesnt appear. What is here wrong?
Regards and thanks


1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 14 Feb 2012, 04:07 PM
Hi Gullo,

Does this issue still appear if you disable the AJAX manager? Are you getting any javascript or server side exceptions? Additionally, try attaching to the UpdateCommand and InsertCommand events in RadGrid and verify they are properly called. Furthermore, using the ItemInserted and ItemUpdated events, you can check if there is an exception that has been thrown internally when trying to update your model. Please provide us with any further info you come across when performing your tests.

Veli
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Grid
Asked by
Gullo
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or