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

Bug in RadGrid, EntityDataSource while using FormTemplate...

3 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Giorgos
Top achievements
Rank 1
Giorgos asked on 18 Aug 2009, 04:46 PM
I have couple days now a problem with the radgrid trying to make a custom visual appearance while editing and inserting using the FormTemplate making EditFormType="Template" but while inserting it keeps giving me databinding eeror that the property does not exist. While editing its ok...i think this is a bug of the control. This is my code:

                    <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" 
                        AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AllowPaging="True" 
                        AllowSorting="True" DataSourceID="edsElegxosBrefos" GridLines="None" Skin="Office2007"
                        <MasterTableView AutoGenerateColumns="False" DataKeyNames="Id" NoMasterRecordsText="Δεν υπάρχουν εξετάσεις..." 
                            DataSourceID="edsElegxosBrefos" PagerStyle-FirstPageToolTip="Πρώτη Σελίδα" PagerStyle-LastPageToolTip="Τελευταία Σελίδα" 
                            PagerStyle-NextPageToolTip="Επόμενη Σελίδα" PagerStyle-NextPagesToolTip="Επόμενες Σελίδες" 
                            PagerStyle-PrevPagesToolTip="Προηγούμενες Σελίδες" PagerStyle-PrevPageToolTip="Προηγούμενη Σελίδα" 
                            PagerStyle-PagerTextFormat="Αλλαγή Σελίδας: {4} &nbsp;Σελίδα <strong>{0}</strong> από <strong>{1}</strong>, Εγγραφές <strong>{2}</strong> εώς <strong>{3}</strong> από <strong>{5}</strong>." 
                            CommandItemSettings-AddNewRecordText="Εισαγωγή Εξέτασης" CommandItemSettings-RefreshText="Ανανέωση" 
                            EditFormSettings-EditFormType="Template" CommandItemDisplay="Bottom"
                            <RowIndicatorColumn> 
                                <HeaderStyle Width="20px" /> 
                            </RowIndicatorColumn> 
                            <ExpandCollapseColumn> 
                                <HeaderStyle Width="20px" /> 
                            </ExpandCollapseColumn> 
                            <CommandItemSettings AddNewRecordText="Εισαγωγή Εξέτασης" RefreshText="Ανανέωση"
                            </CommandItemSettings> 
                            <Columns> 
                                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Edit" ImageUrl="~/Images/edit.png" 
                                    Text="Επεξεργασία" UniqueName="column"
                                </telerik:GridButtonColumn> 
                                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ImageUrl="~/Images/delete.png" 
                                    Text="Διαγραφή εξέτασης" UniqueName="column1"
                                </telerik:GridButtonColumn> 
                                <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" ReadOnly="True" 
                                    SortExpression="Id" UniqueName="Id" Visible="False"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="CheckupDate" DataType="System.DateTime" HeaderText="Ημ. Εξέτασης" 
                                    SortExpression="CheckupDate" UniqueName="CheckupDate"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="Ilikia" DataType="System.Byte" HeaderText="Ηλικία" 
                                    SortExpression="Ilikia" UniqueName="Ilikia"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="Baros" DataType="System.Decimal" HeaderText="Βάρος" 
                                    SortExpression="Baros" UniqueName="Baros"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="Ypsos" DataType="System.Byte" HeaderText="Ύψος" 
                                    SortExpression="Ypsos" UniqueName="Ypsos"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="PerimetrosKefalis" DataType="System.Byte" HeaderText="Περίμετρος Κεφαλής" 
                                    SortExpression="PerimetrosKefalis" UniqueName="PerimetrosKefalis"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="StomatikiKoilotita" HeaderText="Στοματική Κοιλότητα" 
                                    SortExpression="StomatikiKoilotita" UniqueName="StomatikiKoilotita"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="Sxolia" HeaderText="Σχόλια" SortExpression="Sxolia" 
                                    UniqueName="Sxolia"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="Patient.Id" DataType="System.Int32" HeaderText="Patient.Id" 
                                    SortExpression="Patient.Id" UniqueName="Patient.Id" Visible="False"
                                </telerik:GridBoundColumn> 
                            </Columns> 
                            <EditFormSettings EditFormType="Template"
                                <FormTemplate> 
                                    <div align="left"
                                        <table style="width: 100%"
                                            <tr> 
                                                <td style="width: 109px"
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td align="justify" style="width: 109px"
                                                    Ημ.Εξέτασης: 
                                                </td> 
                                                <td> 
                                                    <telerik:RadDatePicker ID="RadDatePickerCheckupDate" runat="server" Culture="Greek (Greece)" 
                                                        DbSelectedDate='<%# Bind("CheckupDate") %>' Skin="Office2007"
                                                        <Calendar Skin="Office2007" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" 
                                                            ViewSelectorText="x"
                                                        </Calendar> 
                                                        <DatePopupButton HoverImageUrl="" ImageUrl="" /> 
                                                    </telerik:RadDatePicker> 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    Ηλικία 
                                                </td> 
                                                <td> 
                                                    <telerik:RadTextBox ID="radTxtBoxIlikia" runat="server" Skin="Office2007" Text='<%# Bind("Ilikia") %>' 
                                                        Width="125px"
                                                    </telerik:RadTextBox> 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td style="width: 109px"
                                                    Βάρος: 
                                                </td> 
                                                <td> 
                                                    <telerik:RadTextBox ID="radTxtBoxBaros" runat="server" Skin="Office2007" Text='<%# Bind("Baros") %>' 
                                                        Width="125px"
                                                    </telerik:RadTextBox> 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    Ύψος: 
                                                </td> 
                                                <td> 
                                                    <telerik:RadTextBox ID="radTxtBoxYpsos" runat="server" Skin="Office2007" Text='<%# Bind("Ypsos") %>' 
                                                        Width="125px"
                                                    </telerik:RadTextBox> 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td style="width: 109px"
                                                    Περίμετρος Κεφαλής: 
                                                </td> 
                                                <td> 
                                                    <telerik:RadTextBox ID="radTxtBoxPerimetrosKefalis" runat="server" Skin="Office2007" 
                                                        Text='<%# Bind("PerimetrosKefalis") %>' Width="125px"
                                                    </telerik:RadTextBox> 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    Στοματική Κοιλότητα: 
                                                </td> 
                                                <td> 
                                                    <telerik:RadTextBox ID="radTxtBoxStomatikiKoilotita" runat="server" Skin="Office2007" 
                                                        Text='<%# Bind("StomatikiKoilotita") %>' Width="125px"
                                                    </telerik:RadTextBox> 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td style="width: 109px"
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td style="width: 109px"
                                                    Σχόλια: 
                                                </td> 
                                                <td> 
                                                    <telerik:RadTextBox ID="radTxtBoxSxolia" runat="server" Skin="Office2007" Text='<%# Bind("Sxolia") %>' 
                                                        Width="250px" Height="150px" TextMode="MultiLine"
                                                    </telerik:RadTextBox> 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    <telerik:RadTextBox ID="radTxtBoxPatientId" runat="server" Skin="Office2007" Text='<%# Bind("Patient.Id") %>' 
                                                        Width="125px" Visible="false"
                                                    </telerik:RadTextBox> 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td style="width: 109px"
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                            </tr> 
                                            <tr> 
                                                <td style="width: 109px"
                                                    <asp:Button ID="btnUpdate" runat="server" Text='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "Εισαγωγή" : "Αποθήκευση" %>' 
                                                        CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>' /> 
                                                    <asp:Button ID="btnCancel" runat="server" CausesValidation="false" Text="Ακύρωση" 
                                                        CommandName="Cancel" /> 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                                <td> 
                                                    &nbsp; 
                                                </td> 
                                            </tr> 
                                        </table> 
                                    </div> 
                                </FormTemplate> 
                            </EditFormSettings> 
                            <PagerStyle FirstPageToolTip="Πρώτη Σελίδα" LastPageToolTip="Τελευταία Σελίδα" NextPagesToolTip="Επόμενες Σελίδες" 
                                NextPageToolTip="Επόμενη Σελίδα" PagerTextFormat="Αλλαγή Σελίδας: {4} &nbsp;Σελίδα &lt;strong&gt;{0}&lt;/strong&gt; από &lt;strong&gt;{1}&lt;/strong&gt;, Εγγραφές &lt;strong&gt;{2}&lt;/strong&gt; εώς &lt;strong&gt;{3}&lt;/strong&gt; από &lt;strong&gt;{5}&lt;/strong&gt;." 
                                PrevPagesToolTip="Προηγούμενες Σελίδες" PrevPageToolTip="Προηγούμενη Σελίδα" /> 
                        </MasterTableView> 
                        <ClientSettings> 
                            <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
                        </ClientSettings> 
                    </telerik:RadGrid> 
        <asp:EntityDataSource ID="edsElegxosBrefos" runat="server" ConnectionString="name=ePediaDBEntities" 
            DefaultContainerName="ePediaDBEntities" EnableDelete="True" EnableInsert="True" 
            AutoGenerateWhereClause="true" Include="Patient" EnableUpdate="True" EntitySetName="CheckupBrefos"
            <WhereParameters> 
                <asp:SessionParameter Name="Patient.Id" SessionField="PatientId" Type="Int32" /> 
            </WhereParameters> 
        </asp:EntityDataSource> 
 

Doublechecked everything tried with new webform from the beginning....nothing...first i thought there is an error with foreign key and the entity data model but when i try to remove one property fails on another....

I think you should check this...thanx

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 21 Aug 2009, 06:35 AM
Hello Giorgos,

This behavior is expected - there is no way for the grid to parse nested properties (in your case Patient.ID). That's why you need to attach an event handler to the ItemCommand event and define it as follows:

    protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
    {  
        if (e.CommandName == RadGrid.InitInsertCommandName)  
        {  
            e.Canceled = true;  
            e.Item.OwnerTableView.InsertItem(new CheckupBrefos());  
        }  
    } 

The above solution is demonstrated in the attached sample.

I hope this information helps.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Shaun Mark
Top achievements
Rank 1
answered on 28 Jun 2011, 08:30 PM
Hi there

I read the response. This is indeed a bug, and this behaviour is not found in dev express or any other advance component sets. By short circuiting the AJAX code on the grid out completely, you get the expected behaviour and stop the Telerik Java Script from having a melt down. This does however prove the point:

    protected void recipientGroupGrid_InsertCommand(object source, GridCommandEventArgs e)
    {
        if (e.Item is GridEditFormItem)
        {
            GridEditFormItem item = (GridEditFormItem)e.Item;
            using (CommunicationsDNNEntity newentity = new CommunicationsDNNEntity())
            {
                InsertData(item, newentity);
            }


            e.Canceled = true;
            Response.Redirect(Request.RawUrl);    // Get the grid to shut the hell up and close. Thank, you I have successfully posted my //record to the database and rebound. The hack proves the bug .... and if I am missing //something and this is by design the Telerik guys need to go back to the drawing //board, Some how it now managed to rebind and show the data :-)
       }
  
    }
0
Tsvetoslav
Telerik team
answered on 01 Jul 2011, 03:19 PM
Hi,

Do upgrade your version of the Telerik controls and use the DefaultInsertValue property of the grid columns. If I have failed to understand your issue, please, provide more detailed and clear information as it is not very straightforward to grasp the problem from your post. 

Best wishes,
Tsvetoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Giorgos
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Shaun Mark
Top achievements
Rank 1
Share this question
or