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

Automatic updates with Usercontrol

5 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve Y
Top achievements
Rank 2
Steve Y asked on 13 Dec 2008, 02:07 AM
I noticed that there's a new feature within RadGrid in the latest release: Q3 2008 SP1 (Version Number 2008.3.1125)


RadGrid

What’s New:

  • Added support for automatic updates with UserControl edit form type if the control implements IBindableControl

Does this mean that a usercontrol edit form can now use standard controls with Bind i.e.

<%` Control Language="C#" AutoEventWireup="true" CodeFile="ucTestGrid.ascx.cs" Inherits="UserControls_ucTestGrid" %> 
 
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FirstName") %>' TabIndex="1" /> 
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("LastName") %>' TabIndex="2" /> 
                                                 
<asp:button id="btnUpdate" text="Update" runat="server" CommandName="Update" /> 
<asp:button id="btnInsert" text="Insert" runat="server" CommandName="PerformInsert" /> 
<asp:button id="btnCancel" text="Cancel" runat="server" causesvalidation="False" commandname="Cancel" /> 

I tried it but could not get the grid to actually perform the update. When I click edit in the grid, it pops up the edit usercontrol with the two textboxes displaying the actual text from the selected row. When I change one of the values and click update, the popup box seems to behave properly (i.e. it closes), there's now error thrown, but the row in the original grid is not updated.

I'm using a simple test grid and a Linq Data Source with inserts, updates and deletes enabled. My Grid has auto updates etc enabled too.

Either my assumption that this is now possible based on the 'what's new' change is mistaken or I've messed up my code.

Any thoughts?

Thanks, Steve


5 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 15 Dec 2008, 07:21 AM
Hello Steve,

Can you post your IBindableControl implementation? Please check the demo from this blog post for more info:
http://blogs.telerik.com/vladimirenchev/posts/08-11-11/Automatic_insert_update_and_delete_with_UserControl_edit_form_for_the_grid.aspx

All the best,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steve Y
Top achievements
Rank 2
answered on 15 Dec 2008, 08:11 AM
Vlad,

Thanks for the link to the example. I followed it and finally realized I had not named the textbox IDs the same as the field names. Changed my code and it all works perfectly.

Thanks. Steve
0
Alexandre Lepage
Top achievements
Rank 1
answered on 06 Jan 2009, 04:28 PM
I'd like to do the same but with Manual update.

like in :
    protected void rgCA_UpdateCommand(object source, GridCommandEventArgs e) 
    { 
        GridItem editItem = (GridItem)e.Item; 
        vPersonneDetail cm = GridData[ItemIndex(editItem)]; 
        cm.PersonneNom = (editItem.FindControl("PersonneNom") as RadTextBox).Text; 
 
        //Assign_rgCA(ref cm, e); 
        //GridData.RemoveAt(ItemIndex(editItem)); 
        //GridData.Insert(ItemIndex(editItem), cm); 
        //e.Item.Edit = false
    } 
 

When I arrive at the line
cm.PersonneNom = (editItem.FindControl("PersonneNom") as RadTextBox).Text;
Find Control return null
 (GridData is my RadGrid1.DataSource of type List<vPersonneDetail>)

Thanks!



0
Sebastian
Telerik team
answered on 06 Jan 2009, 04:31 PM
Hello Alexandre,

Review the implementation from the following online resources to learn how to perform manual updates with WebUserControl custom edit form:

http://demos.telerik.com/aspnet-ajax/Grid/Examples/DataEditing/UserControlEditForm/DefaultCS.aspx
http://www.telerik.com/help/aspnet-ajax/grdupdatingvaluesusercontrolformtemplate.html
http://www.telerik.com/help/aspnet-ajax/grdinsertingvaluesusercontrolformtemplate.html

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alexandre Lepage
Top achievements
Rank 1
answered on 06 Jan 2009, 09:03 PM
Exactly what I needed :-)

Thanks a lot :-)
Tags
Grid
Asked by
Steve Y
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Steve Y
Top achievements
Rank 2
Alexandre Lepage
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or