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

Grid using Edit template

5 Answers 50 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Arno
Top achievements
Rank 2
Arno asked on 12 Nov 2008, 03:21 PM
Hi,

I'm currently creating a grid where the user can add, edit and delete at runtime. Deleting a record is quite easy, but I can't seem to figure out how I can edit a record. I went through quite a few demo's, but I couln'd find a very simple example to illustrate this basic functionality.

Like this demo:
http://demos.telerik.com/aspnet/prometheus/Grid/Examples/Programming/WebGrid/DefaultCS.aspx
I want to create such an edit form. Is there a very simple demo which illustrates just this?

Thanks,
Arno

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Nov 2008, 03:24 PM
Hello Arno,

Please check this demo for more info:
http://demos.telerik.com/aspnet/Prometheus/Grid/Examples/DataEditing/TemplateFormUpdate/DefaultCS.aspx

Greetings,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Arno
Top achievements
Rank 2
answered on 13 Nov 2008, 07:52 AM
Hi Vlad,

I'm a bit further, but there is one thing going wrong ad I can't get it solved.
The grid starts empty and will be filled at runtime by user input only. So I add two records and decide to change one of them. As soon as I click the edit-link,  the entire grid shrinks to the size of a horizontal line rendering it useless. Only when I add another record, the grid is shown normal again and can I see that my Edit template is working correctly. Do you know what I am doing wrong?

aspx code
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" UpdatePanelsRenderMode="Inline">  
  <AjaxSettings> 
    <telerik:AjaxSetting AjaxControlID="rgKinderen">  
      <UpdatedControls> 
        <telerik:AjaxUpdatedControl ControlID="rgKinderen" /> 
      </UpdatedControls> 
    </telerik:AjaxSetting> 
  </AjaxSettings> 
</telerik:RadAjaxManager> 
<telerik:RadGrid ID="rgKinderen" runat="server" OnDeleteCommand="rgKinderen_DeleteCommand" 
  OnSelectedIndexChanged="rgKinderen_SelectedIndexChanged" OnItemDataBound="rgKinderen_ItemDataBound" 
  OnPreRender="rgKinderen_PreRender">  
  <ClientSettings> 
    <Selecting AllowRowSelect="true" /> 
  </ClientSettings> 
  <MasterTableView DataKeyNames="Naam">  
    <Columns> 
      <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Verwijder" CommandName="Delete" /> 
      <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn> 
    </Columns> 
    <RowIndicatorColumn Visible="True">  
      <HeaderStyle Width="20px" /> 
    </RowIndicatorColumn> 
    <ExpandCollapseColumn Resizable="False" Visible="False">  
      <HeaderStyle Width="20px" /> 
    </ExpandCollapseColumn> 
    <EditFormSettings EditFormType="Template">  
      <FormTemplate> 
        <table id="tblInlineKinderen" cellspacing="2" cellpadding="1" width="100%" border="0">  
          <tr> 
            <td>Naam:</td> 
            <td><telerik:RadTextBox ID="rtbInternNaamKind" runat="server" Text='<%# Bind( "Naam") %>'></telerik:RadTextBox></td>  
          </tr> 
          <tr> 
            <td>Geboortedatum:</td> 
            <td><telerik:RadDatePicker ID="rdpInterGebDat" runat="server" SelectedDate='<%# Bind( "Geboortedatum") %>'></telerik:RadDatePicker></td>  
          </tr> 
        </table> 
      </FormTemplate> 
    </EditFormSettings> 
  </MasterTableView> 
</telerik:RadGrid> 
0
Arno
Top achievements
Rank 2
answered on 17 Nov 2008, 12:41 PM
Is my question clear? Or does anyone need more information to help me further? Please feel free to ask, because any help is greatly appreciated.

Arno
0
Accepted
Sebastian
Telerik team
answered on 17 Nov 2008, 12:47 PM
Hello Arno,

Can you please verify that you are using advanced binding with NeedDataSource event handling or assigning a data source control for grid content generator? This should ensure that the grid will be rebound on edit/sort/paging/etc. operation and will visualize the data as expected. Furthermore, advanced operations like grouping, custom edit forms, filtering and so on will not require any additional coding.

Regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Arno
Top achievements
Rank 2
answered on 17 Nov 2008, 03:15 PM
Hi Stephen,

Your hint really helped me. But I'm a little ashamed to say what the problem was... Because I needed to write a handler for both the delete and the insert action and NOT for the edit action, I forgot to rebind the data when editing. I used the PreRender method to initialize the grid, but forgot to refill the DataSet. This way the grid was boud with an empty DataSet.

Thanks again. Now it works perfectly.

Arno
Tags
Ajax
Asked by
Arno
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Arno
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or