Grid with Edit Template using an ObjectDataSource

2 posts, 0 answers
  1. Malcolm
    Malcolm avatar
    1 posts
    Member since:
    Jun 2010

    Posted 28 Jun 2010 Link to this post

    I have a radgrid that uses an EditTemplate for the purposes of updating the data. For my Datasource i am using an objectdatasource. At runtime when i go to edit a record, the edit panel loads the data is populated correctly, but when i click update and try to save the changes i have made, the EditTemplate is not hooked up to my ObjectDataSource.

    Any Ideas?

    <telerik:RadGrid ID="rgTimeSheetGrid"  
        runat="server"  
        CssClass="RadGrid"  
        GridLines="None"  
        AllowPaging="True"  
        PageSize="20"  
        AutoGenerateColumns="False"  
        AllowAutomaticDeletes="True" 
        AllowAutomaticInserts="True" 
        AllowAutomaticUpdates="True" 
        DataSourceID="TaskDataSource"  
        ShowStatusBar="True"  
        AutoGenerateEditColumn="True" 
        AutoGenerateDeleteColumn="True" 
        OnItemDataBound="radTimesheetEntry_ItemDataBound" 
        OnItemUpdated="radTimesheetEntry_OnItemUpdated"
        <HeaderContextMenu EnableAutoScroll="True"></HeaderContextMenu> 
     
        <MasterTableView 
            DataSourceID="TaskDataSource"  
            ShowGroupFooter="true"  
            CommandItemDisplay="Top"  
            EditMode="EditForms"  
            DataKeyNames="ID" 
            RowIndicatorColumn-HeaderStyle-Width="20px"  
            ExpandCollapseColumn-HeaderStyle-Width="20px"
            <GroupByExpressions> 
                <telerik:GridGroupByExpression> 
                    <SelectFields> 
                        <telerik:GridGroupByField FieldAlias="Date" FieldName="Date"></telerik:GridGroupByField> 
                    </SelectFields> 
                    <GroupByFields> 
                        <telerik:GridGroupByField FieldName="Date" SortOrder="None"></telerik:GridGroupByField> 
                    </GroupByFields> 
                </telerik:GridGroupByExpression> 
            </GroupByExpressions> 
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <Columns> 
                <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" HeaderText="ID" SortExpression="ID" UniqueName="ID" Visible="false" /> 
                <telerik:GridBoundColumn DataField="Date" HeaderText="Date" SortExpression="Date" UniqueName="Date" Visible="false" /> 
                <telerik:GridBoundColumn DataField="Project" HeaderText="Project" SortExpression="Project" UniqueName="Project" /> 
                <telerik:GridBoundColumn DataField="Activity" HeaderText="Activity" SortExpression="Activity" UniqueName="Activity" /> 
                <telerik:GridBoundColumn DataField="Role" HeaderText="Role" SortExpression="Role" UniqueName="Role" /> 
                <telerik:GridBoundColumn DataField="Notes" Visible="false" HeaderText="Notes" SortExpression="Notes" UniqueName="Notes" /> 
                <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" UniqueName="Description" /> 
                <telerik:GridBoundColumn DataField="Hours" DataType="System.Double" HeaderText="Hours" SortExpression="Hours" UniqueName="Hours" /> 
            </Columns> 
            <CommandItemTemplate> 
                <asp:LinkButton ID="lnkAddEntry" runat="server" CommandName="InitInsert">Add Entry</asp:LinkButton> 
            </CommandItemTemplate> 
            <EditFormSettings EditFormType="Template"
                <FormTemplate> 
                    <table id="ManageRecord" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none" 
                        style="border-collapse: collapse; background: white;"
                        <tr> 
                            <td> 
                                <table id="ManageLeft" cellspacing="1" cellpadding="1" width="250" border="0" class="module"
                                    <tr> 
                                        <td>Project</td> 
                                        <td><asp:DropDownList id="ddProject" runat="server"></asp:DropDownList></td
                                    </tr> 
                                    <tr> 
                                        <td>Activity</td> 
                                        <td><asp:DropDownList id="ddActivity" runat="server"></asp:DropDownList></td
                                    </tr> 
                                    <tr> 
                                        <td>Role</td> 
                                        <td><asp:DropDownList id="ddRole" runat="server"></asp:DropDownList></td
                                    </tr> 
                                    <tr> 
                                        <td>Date</td> 
                                        <td><asp:DropDownList ID="ddDate" runat="server"></asp:DropDownList></td
                                    </tr> 
     
                                </table> 
                            </td> 
                            <td> 
                                <table id="ManageRight" cellspacing="1" cellpadding="1" width="250" border="0" class="module"
                                    <tr> 
                                        <td>Hours</td> 
                                        <td><asp:TextBox ID="txtHours" runat="server" ></asp:TextBox></td
                                    </tr> 
                                    <tr> 
                                        <td>Note</td> 
                                        <td><asp:TextBox ID="txtNotes" runat="server" ></asp:TextBox></td
                                    </tr> 
                                    <tr> 
                                        <td>Description</td> 
                                        <td><asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" ></asp:TextBox></td
                                    </tr> 
                                </table> 
                            </td> 
                        </tr> 
                        <tr> 
                            <td align="right" colspan="2"
                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button>&nbsp; 
                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button> 
                            </td> 
                        </tr> 
                    </table> 
                </FormTemplate> 
            </EditFormSettings>   
        </MasterTableView> 
        <ClientSettings> 
            <ClientEvents OnRowDblClick="RowDblClick" /> 
        </ClientSettings> 
    </telerik:RadGrid> 
    <asp:ObjectDataSource ID="TaskDataSource" runat="server"  
        DeleteMethod="Delete" InsertMethod="Create" SelectMethod="Select"  
        TypeName="T4G.TIM.Web.Data.TaskController" UpdateMethod="Update" > 
        <DeleteParameters> 
            <asp:Parameter Name="ID" Type="Int32" /> 
            <asp:Parameter Name="Project" Type="String" /> 
            <asp:Parameter Name="Activity" Type="String" /> 
            <asp:Parameter Name="Role" Type="String" /> 
            <asp:Parameter Name="Hours" Type="Double" /> 
            <asp:Parameter Name="Notes" Type="String" /> 
            <asp:Parameter Name="Description" Type="String" /> 
            <asp:Parameter Name="Date" Type="String" /> 
        </DeleteParameters> 
        <UpdateParameters> 
            <asp:Parameter Name="ID" Type="Int32" /> 
            <asp:Parameter Name="Project" Type="String" /> 
            <asp:Parameter Name="Activity" Type="String" /> 
            <asp:Parameter Name="Role" Type="String" /> 
            <asp:Parameter Name="Hours" Type="Double" /> 
            <asp:Parameter Name="Notes" Type="String" /> 
            <asp:Parameter Name="Description" Type="String" /> 
            <asp:Parameter Name="Date" Type="String" /> 
        </UpdateParameters> 
        <InsertParameters> 
            <asp:Parameter Name="ID" Type="Int32" /> 
            <asp:Parameter Name="Project" Type="String" /> 
            <asp:Parameter Name="Activity" Type="String" /> 
            <asp:Parameter Name="Role" Type="String" /> 
            <asp:Parameter Name="Hours" Type="Double" /> 
            <asp:Parameter Name="Notes" Type="String" /> 
            <asp:Parameter Name="Description" Type="String" /> 
            <asp:Parameter Name="Date" Type="String" /> 
        </InsertParameters> 
    </asp:ObjectDataSource> 

  2. Martin
    Admin
    Martin avatar
    833 posts

    Posted 01 Jul 2010 Link to this post

    Hello Malcolm,

    I would suggest that you review the following help article and online demo:

    Two-way declarative binding
    Form template edit form

    I hope this helps

    Regards,
    Martin
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top