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

RadGrid - can't get inline editing and other things to work

3 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 09 Oct 2012, 05:01 PM
I have followed numerous tutorials and example and I have several problems with my simple example below.

1. Paging controls don't show
2. The OnInsertCommand gets called and my code actually inserts a record using a class I have created for that purpose.
3. The grid populates with my IEnumerable<myclass> data returned.
4.The Insert Record row shows at the top after clicking on "Add New Record" link; but does not go away after the record inserts!
5. The grid does not refresh after inserting a new record.

What am I doing wrong?

 

<
telerik:RadAjaxManager ID="radAjaxManager" runat="server">
                   <AjaxSettings>
                       <telerik:AjaxSetting AjaxControlID="radAjaxManager">
                           <UpdatedControls>
                               <telerik:AjaxUpdatedControl ControlID="radGridAchievements" />
                           </UpdatedControls>
                       </telerik:AjaxSetting>
                   </AjaxSettings>
               </telerik:RadAjaxManager>
 
               <telerik:RadGrid ID="radGridAchievements" runat="server"
                   AutoGenerateColumns="false" DataSourceID="odsAchievements"
                   AllowAutomaticInserts="true"
                   PageSize="5" AllowPaging="true"
                   OnInsertCommand="radGridAchievements_InsertCommand" OnItemInserted="radGridAchievements_OnItemInserted">
                   <PagerStyle Mode="NextPrevAndNumeric" />
                   <MasterTableView DataKeyNames="Id" DataSourceID="odsAchievements"
                       EditMode="InPlace" CommandItemDisplay="TopAndBottom">
                       <Columns>
                           <telerik:GridEditCommandColumn ButtonType="LinkButton" />
                           <telerik:GridTemplateColumn DataField="Title" HeaderText="Title" >
                               <ItemTemplate>
                                   <%# Eval("Title") %>
                               </ItemTemplate>
                               <InsertItemTemplate>
                                   <telerik:RadTextBox ID="txtTitleInsert" runat="server" />
                               </InsertItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn DataField="Description" HeaderText="Description">
                               <ItemTemplate>
                                   <%# Eval("Description") %>
                               </ItemTemplate>
                               <InsertItemTemplate>
                                   <telerik:RadTextBox ID="txtDescriptionInsert" runat="server" />
                               </InsertItemTemplate>
                           </telerik:GridTemplateColumn>
                        </Columns>
                   </MasterTableView>
                   <ClientSettings AllowKeyboardNavigation="true">
                       <KeyboardNavigationSettings AllowSubmitOnEnter="true"/>
                       <ClientEvents
                                     OnGridCreated="OnAchievementGridCreated" />
                   </ClientSettings>
                   <ValidationSettings EnableValidation="true" CommandsToValidate="PerformInsert, Update" />
               </telerik:RadGrid>
 
               <asp:ObjectDataSource ID="odsAchievements" runat="server"
                   TypeName="GamesPlatform.External.Web.App.AchievementManager"
                   SelectMethod="GetAchievements"
                   OnObjectCreating="odsAchievements_ObjectCreating"
                   OnObjectDisposing="odsAchievements_ObjectDisposing" />

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Oct 2012, 05:19 AM
Hello,

Please try with below code.

<telerik:RadAjaxManager ID="radAjaxManager" runat="server">
           <AjaxSettings>
               <telerik:AjaxSetting AjaxControlID="radGridAchievements">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="radGridAchievements" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
           </AjaxSettings>
       </telerik:RadAjaxManager>

OR

<telerik:RadAjaxManager ID="radAjaxManager" runat="server">
           <AjaxSettings>
               <telerik:AjaxSetting AjaxControlID="radAjaxManager">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="radGridAchievements" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
               <telerik:AjaxSetting AjaxControlID="radGridAchievements">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="radGridAchievements" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
           </AjaxSettings>
       </telerik:RadAjaxManager>



Thanks,
Jayesh Goyani
0
Jeff
Top achievements
Rank 1
answered on 10 Oct 2012, 05:00 PM
Hi Jayesh,

I certainly appreciate you taking the time to look at this. I would be interested in knowing why you thought your proposed changes would have changed anything. I think it would be helpful for anyone posting here to get, in addition to the proposed code changes, the "why" of where the problem is and what fixes it. In either case, your proposed changes had no effect.

The solution, as it turns out, was to remove the AllowAutomaticInserts. After that grid refresh and removal of the insert row worked as expected.

Thanks again,
Jeff
0
Eyup
Telerik team
answered on 12 Oct 2012, 11:06 AM
Hello Jeff,

I am really glad that you have overcome the issue by yourself.

Indeed, when updating, inserting, or deleting records from your grid manually, their regarding AllowAutomatic operation properties are totally unnecessary.

In your provided sample mark-up, I have noticed that you have duplicate OnInsertCommand definition. Please remove one of them to prevent any unwanted issues with the event.

Please let us know if new issues arise.

In addition, you could also check out the following code library which demonstrates performing manual CRUD operations with SQL datasource:
http://www.telerik.com/community/code-library/aspnet-ajax/grid/manual-insert-update-delete-operations-using-auto-generated-editform-with-sql-statements-from-the-code-behind.aspx

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Jeff
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or