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

Rebinding problem in nested RadGrid

5 Answers 199 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Muhammad
Top achievements
Rank 1
Muhammad asked on 25 Jan 2012, 05:30 PM
Hi,

I am using nested radgrid in which I have at the top is Quotations then Groups and then Items. I want to calculate the total cost of Items in each group but the problem is that whenever I rebind a radgrid after adding a new Item it's giving me the following the exception. The purpose of rebinding is that I want to display a total in lblTotalCost in an itemdatabound event, and if I don't do rebind then it doesn't give me any exception.

Any help would be greatly appreciated.

Thanks.

Exception : DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ItemName'.

<telerik:RadGrid ID="rgQuotation" runat="server" Width="95%" ShowStatusBar="true"
            Skin="Office2007" Font-Names="Verdana" AutoGenerateHierarchy="true" AutoGenerateColumns="False"
            AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="false" ShowFooter="True">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView Width="100%" DataKeyNames="ID" AllowMultiColumnSorting="True" CommandItemDisplay="Top"
                HierarchyDefaultExpanded="true" HierarchyLoadMode="ServerBind" Name="Quotation"
                CssClass="DetailTable_Default">
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"
                        ItemStyle-Width="30px" EditImageUrl="~/Portals/0/Images/Edit.gif">
                        <ItemStyle BackColor="GreenYellow" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn SortExpression="ID" HeaderText="ID" HeaderButtonType="TextButton"
                        DataField="ID" UniqueName="ID" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="TariffName" HeaderText="Quotation Name"
                        HeaderButtonType="TextButton" DataField="TariffName" UniqueName="TariffName"
                        ReadOnly="true">
                        <ItemStyle BackColor="GreenYellow" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="RecordType" HeaderText="Rec Type" HeaderButtonType="TextButton"
                        DataField="RecordType" UniqueName="RecordType" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="JobID" HeaderText="Job No" HeaderButtonType="TextButton"
                        DataField="JobID" UniqueName="JobID" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn UniqueName="ShowTotal">
                        <ItemStyle Width="125px" HorizontalAlign="Left" BackColor="Yellow" />
                        <FooterTemplate>
                            <asp:Label ID="lblTotalCost" runat="server" Text="dffsafssdf" Font-Bold="true" ForeColor="White"
                                Font-Italic="true">
                            </asp:Label>
                            <asp:Label ID="lblTotalSelling" runat="server" Text="Total Selling" Font-Bold="true"
                                Visible="false">
                            </asp:Label>
                        </FooterTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
                <EditFormSettings EditFormType="Template" InsertCaption="New Tariff">
                    <FormTemplate>
                        <div>
                            <asp:Label ID="lblTariffName" runat="server" Text="Quotation Name" CssClass="fieldsetControlStyle">
                            </asp:Label>
                               
                            <asp:TextBox ID="txtTariffName" runat="server" Text='<%# Eval("TariffName") %>'>
                            </asp:TextBox>
                            <asp:LinkButton ID="lnkbtnUpdate" runat="server" CausesValidation="True" CommandName='<%# IIf( DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "PerformInsert", "Update") %>'
                                CssClass="lnkButton" ToolTip="Update">
                                <asp:Image ID="imgUpdate" runat="server" ImageUrl="~/Portals/0/Images/Update.gif" />
                            </asp:LinkButton>
                             <asp:LinkButton ID="lnkbtnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                                CssClass="lnkButton" ToolTip="Cancel">
                                <asp:Image ID="imgCancel" runat="server" ImageUrl="~/Portals/0/Images/Cancel.gif" />
                            </asp:LinkButton>
                        </div>
                    </FormTemplate>
                </EditFormSettings>
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="ID" HierarchyLoadMode="ServerBind" Width="100%"
                        HierarchyDefaultExpanded="true" CommandItemDisplay="Top" runat="server" Name="Groups"
                        CssClass="DetailTable_Default">
                        <Columns>
                            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"
                                ItemStyle-Width="40px" EditImageUrl="~/Portals/0/Images/Edit.gif">
                                <ItemStyle BackColor="Yellow" />
                            </telerik:GridEditCommandColumn>
                            <telerik:GridBoundColumn SortExpression="GroupID" HeaderText="GroupID" HeaderButtonType="TextButton"
                                DataField="GroupID" UniqueName="GroupID" ReadOnly="true" Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="GroupName" HeaderText="Group Name" HeaderButtonType="TextButton"
                                DataField="GroupName" UniqueName="GroupName">
                                <ItemStyle Font-Bold="true" BackColor="Yellow" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="TariffID" HeaderText="TariffID" HeaderButtonType="TextButton"
                                DataField="TariffID" UniqueName="TariffID" ReadOnly="true" Visible="false">
                                <ItemStyle Width="0%" />
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="ShowTotal">
                                <ItemStyle Width="125px" HorizontalAlign="Left" BackColor="Yellow" />
                                <FooterTemplate>
                                    <asp:Label ID="lblTotalCost" runat="server" Text="" Font-Bold="true" ForeColor="White"
                                        Visible="true" Font-Italic="true">
                                    </asp:Label>
                                    <asp:Label ID="lblTotalSelling" runat="server" Text="Total Selling" Font-Bold="true"
                                        Visible="false">
                                    </asp:Label>
                                </FooterTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                        <EditFormSettings EditFormType="Template" InsertCaption="New Group">
                            <FormTemplate>
                                <div>
                                    <asp:Label ID="lblGroupName" runat="server" Text="Group Name" CssClass="fieldsetControlStyle">
                                    </asp:Label>
                                       
                                    <asp:TextBox ID="txtGroupName" runat="server" Text='<%# Eval("groupname") %>'>
                                    </asp:TextBox>
                                    <br />
                                    <asp:LinkButton ID="lnkbtnUpdate" runat="server" CausesValidation="True" CommandName='<%# IIf( DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "PerformInsert", "Update") %>'
                                        CssClass="lnkButton">
                                        <asp:Image ID="imgUpdate" runat="server" ImageUrl="~/Portals/0/Images/Update.gif" />
                                    </asp:LinkButton>
                                     <asp:LinkButton ID="lnkbtnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                                        CssClass="lnkButton" ToolTip="Cancel">
                                        <asp:Image ID="imgCancel" runat="server" ImageUrl="~/Portals/0/Images/Cancel.gif" />
                                    </asp:LinkButton>
                                </div>
                            </FormTemplate>
                        </EditFormSettings>
                        <CommandItemSettings AddNewRecordText="Add New Group" AddNewRecordImageUrl="~/Portals/0/Images/AddRecord.gif"
                            ShowRefreshButton="false" />
                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="ID" Width="100%" Name="Items" CommandItemDisplay="Top"
                                AlternatingItemStyle-BackColor="SkyBlue" CssClass="DetailTable_Default!" EditMode="InPlace"
                                runat="server" HierarchyLoadMode="ServerBind">
                                <Columns>
                                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"
                                        UpdateImageUrl="~/Portals/0/Images/Update.gif" ItemStyle-Width="40px" EditImageUrl="~/Portals/0/Images/Edit.gif"
                                        CancelImageUrl="~/Portals/0/Images/Cancel.gif">
                                    </telerik:GridEditCommandColumn>
                                    <telerik:GridBoundColumn SortExpression="ID" HeaderText="ID" HeaderButtonType="TextButton"
                                        DataField="ID" UniqueName="ID" ReadOnly="true" Visible="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression="ItemOrder" HeaderText="ItemOrder" HeaderButtonType="TextButton"
                                        DataField="ItemOrder" UniqueName="ItemOrder" ReadOnly="true" Visible="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn HeaderText="Item Name">
                                        <ItemTemplate>
                                            <asp:Label ID="lblItemName" runat="server" Text='<%# Eval("ItemName") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:TextBox ID="txtItemName" runat="server" Text='<%# Eval("ItemName") %>' MaxLength="100">
                                            </asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvtxtItemName" runat="server" ErrorMessage="!" Display="Dynamic"
                                                ControlToValidate="txtItemName">
                                            </asp:RequiredFieldValidator>
                                        </EditItemTemplate>
                                        <ItemStyle Width="30%" />
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Rate" UniqueName="Rate">
                                        <ItemTemplate>
                                            <asp:Label ID="lblUnits" runat="server" Text='<%# Eval("Units") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <telerik:RadNumericTextBox ID="rntbRate" ShowSpinButtons="true" IncrementSettings-InterceptArrowKeys="true"
                                                IncrementSettings-InterceptMouseWheel="true" runat="server" Type="Number" Width="80px"
                                                DbValue='<%# Eval("Units") %>' NumberFormat-DecimalDigits="2" MinValue="1" IncrementSettings-Step="1"
                                                CssClass="fieldsetControlWidth fieldsetLine" />
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Quantity" UniqueName="Quantity">
                                        <ItemTemplate>
                                            <asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("Quantity") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <telerik:RadNumericTextBox ID="rntbQuantity" ShowSpinButtons="true" IncrementSettings-InterceptArrowKeys="true"
                                                IncrementSettings-InterceptMouseWheel="true" runat="server" Type="Number" Width="80px"
                                                DbValue='<%# Eval("Quantity") %>' NumberFormat-DecimalDigits="0" MinValue="0"
                                                IncrementSettings-Step="1" CssClass="fieldsetControlWidth fieldsetLine">
                                                <ClientEvents OnBlur="Blur" OnFocus="Focus" />
                                            </telerik:RadNumericTextBox>
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="C.P" UniqueName="CostPrice">
                                        <ItemTemplate>
                                            <asp:Label ID="lblCostPrice" runat="server" Text='<%# Format(DataBinder.Eval(Container.DataItem,"CostPrice"),"###,##0.00") %>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <telerik:RadNumericTextBox ID="rntbCostPrice" ShowSpinButtons="true" IncrementSettings-InterceptArrowKeys="true"
                                                IncrementSettings-InterceptMouseWheel="true" runat="server" Type="Number" Width="80px"
                                                DbValue='<%# Eval("CostPrice") %>' NumberFormat-DecimalDigits="2" MinValue="0"
                                                IncrementSettings-Step="1" CssClass="fieldsetControlWidth fieldsetLine" />
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="S.P" Visible="false">
                                        <ItemTemplate>
                                            <asp:Label ID="lblSellingPrice" runat="server" Text='<%# Format(DataBinder.Eval(Container.DataItem,"SellingPrice"),"###,##0.00") %>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <telerik:RadNumericTextBox ID="rntbSellingPrice" ShowSpinButtons="true" IncrementSettings-InterceptArrowKeys="true"
                                                IncrementSettings-InterceptMouseWheel="true" runat="server" Type="Number" Width="80px"
                                                DbValue='<%# Eval("SellingPrice") %>' NumberFormat-DecimalDigits="2" MinValue="0"
                                                IncrementSettings-Step="1" CssClass="fieldsetControlWidth fieldsetLine" />
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <%--                                    <telerik:GridCalculatedColumn HeaderText="C.P Total" DataType="System.Double" UniqueName="TotalCostPrice"
                                        FooterStyle-Font-Bold="true" FooterStyle-ForeColor="White" DataFields="CostPrice,Units,Quantity"
                                        Expression="{0}/{1}*{2}" Aggregate="Sum" DataFormatString="{0:###,##0.00}" FooterAggregateFormatString="{0:£###,##0.00}" />
                                    <telerik:GridCalculatedColumn HeaderText="S.P Total " UniqueName="TotalSellingPrice"
                                        FooterStyle-ForeColor="White" FooterStyle-Font-Bold="true" Visible="false" DataFields="SellingPrice,Units,Quantity"
                                        Expression="{0}/{1}*{2}" DataType="System.Double" FooterAggregateFormatString="{0:£###,##0.00}"
                                        FooterText="S.P Total : " Aggregate="Sum" DataFormatString="{0:###,##0.00}" />--%>
                                </Columns>
                                <CommandItemSettings AddNewRecordText="Add New Item" AddNewRecordImageUrl="~/Portals/0/Images/AddRecord.gif"
                                    ShowRefreshButton="false" />
                            </telerik:GridTableView>
                        </DetailTables>
                    </telerik:GridTableView>
                </DetailTables>
                <CommandItemSettings AddNewRecordText="Add new Quotation" AddNewRecordImageUrl="~/Portals/0/Images/AddRecord.gif"
                    ShowRefreshButton="false" ShowExportToPdfButton="true" />
            </MasterTableView>
            <ClientSettings AllowKeyboardNavigation="true" EnableRowHoverStyle="true">
                <ClientEvents OnRowContextMenu="RowContextMenu" OnRowDblClick="RowDblClick" />
                <Selecting AllowRowSelect="true" />
                <KeyboardNavigationSettings EnableKeyboardShortcuts="true" AllowSubmitOnEnter="true"
                    AllowActiveRowCycle="true" CollapseDetailTableKey="LeftArrow" ExpandDetailTableKey="RightArrow" />
            </ClientSettings>
        </telerik:RadGrid>
 
 
Protected Sub rgQuotation_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgQuotation.ItemCommand
 
        If e.CommandName = "PerformInsert" Then
 
            Insert(e)          
            rgQuotation.Rebind()
 
        ElseIf e.CommandName = "Update" Then
            Update(e)
            rgQuotation.Rebind()
        End If
 
    End Sub
 
  Protected Sub rgQuotation_DetailTableDataBind(ByVal source As Object, ByVal e As GridDetailTableDataBindEventArgs) Handles rgQuotation.DetailTableDataBind
 
        Dim sql As String
        Dim sb As New StringBuilder
        Dim dt As DataTable
 
        Select Case e.DetailTableView.Name
 
            Case "Groups"
 
                Dim nTariffId As String = e.DetailTableView.ParentItem.GetDataKeyValue("ID").ToString()
 
                sb.Append("select * from ff_Group where TariffID = " & nTariffId & " and IsDeleted = 0 order by grouporder")
                sql = sb.ToString
 
                dt = DNNDB.Query(sql)          
 
                e.DetailTableView.DataSource = dt
 
 
            Case "Items"
 
                Dim nGroupId As String = e.DetailTableView.ParentItem.GetDataKeyValue("ID").ToString()
 
                sb.Append("select * from FF_Item where FF_Item.GroupID = " & nGroupId & " and IsDeleted = 0 order By ItemOrder asc")
                sql = sb.ToString
 
                dt = DNNDB.Query(sql)
 
                e.DetailTableView.DataSource = dt
 
        End Select
 
    End Sub
 
Protected Sub rgQuotation_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgQuotation.NeedDataSource
 
        BindQuotation()
 
    End Sub

 Protected Sub BindQuotation()

        Dim sb As New StringBuilder
        sb.Append("select * from ff_tariff where JobID = " & pnJobID & " and Isdeleted = 0 and RecordType = '" & FF_GLOBALS.RECORD_TYPE_QUOTATION & "'")
        Dim sql As String = sb.ToString


        Dim dt As DataTable = DNNDB.Query(sql)
        rgQuotation.DataSource = dt  


    End Sub


5 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 30 Jan 2012, 04:06 PM
Hi,

Based on the provided information there are two possible reasons for this exception:

  • There is no ItemName field in the FF_Item table and thus when you are performing Rebind the field could not be found.
  • Second possibility is if you are modifying the datasource in the ItemDataBound event.

Could you post your ItemDataBound event handler?


All the best,
Andrey
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
0
Muhammad
Top achievements
Rank 1
answered on 30 Jan 2012, 06:29 PM
Hi,

The ItemName field exists in FF_Item table, the problem occurs when I update the row of Item table and again rebind my grid rgQuotation.Rebind() then I get this exception.

 Protected Sub rgQuotation_DetailTableDataBind(ByVal source As Object, ByVal e As GridDetailTableDataBindEventArgs) Handles rgQuotation.DetailTableDataBind


        Dim sql As String
        Dim sb As New StringBuilder
        Dim dt As DataTable


        Select Case e.DetailTableView.Name


            Case "Groups"


                Dim nTariffId As String = e.DetailTableView.ParentItem.GetDataKeyValue("ID").ToString()


                sb = New StringBuilder
                sb.Append("select ID, GroupName, GroupOrder, TariffID, IsDeleted, CreatedOn, CreatedBy from ff_Group where TariffID = " & nTariffId & " and IsDeleted = 0 order by grouporder")
                sql = sb.ToString


                dt = DNNDB.Query(sql)            




            Case "Items"


                Dim nGroupId As String = e.DetailTableView.ParentItem.GetDataKeyValue("ID").ToString()


                sb = New StringBuilder


                sb.Append("select ff_Item.ID, ff_Item.ItemName, ff_Item.ItemOrder, ff_Item.Quantity, ff_Item.Units, ff_Item.CostPrice, ff_Item.SellingPrice, GroupID, IsDeleted, CreatedOn, CreatedBy ")
                sb.Append("from FF_Item where FF_Item.GroupID = " & nGroupId & " and IsDeleted = 0 order By ItemOrder asc")
                sql = sb.ToString


                dt = DNNDB.Query(sql)


                e.DetailTableView.DataSource = dt

             




        End Select


    End Sub
 
  Protected Sub rgQuotation_ItemDataBound(ByVal source As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgQuotation.ItemDataBound
        If TypeOf e.Item Is GridDataItem And e.Item.OwnerTableView.Name = "Items" And e.Item.IsInEditMode Then
 
            Dim rntbRate As RadNumericTextBox = e.Item.FindControl("rntbRate")
            Dim rntbQuantity As RadNumericTextBox = e.Item.FindControl("rntbQuantity")
            Dim rntbCostPrice As RadNumericTextBox = e.Item.FindControl("rntbCostPrice")
 
 
 
        ElseIf TypeOf e.Item Is GridDataItem And e.Item.OwnerTableView.Name = "Items" And e.Item.IsInEditMode = False Then
 
            Dim lblUnits As Label = e.Item.FindControl("lblUnits")
            Dim lblQuantity As Label = e.Item.FindControl("lblQuantity")
            Dim lblCostPrice As Label = e.Item.FindControl("lblCostPrice")
            Dim lblSellingPrice As Label = e.Item.FindControl("lblSellingPrice")
            Dim lblMargin As Label = e.Item.FindControl("lblMargin")
            Dim lblProfit As Label = e.Item.FindControl("lblProfit")
 
            Dim dCostPrice As Decimal = 0
            Dim dInvoice As Decimal = 0
            Dim nQuantity As Integer = 0
            Dim dProfit As Decimal = 0
            Dim dMargin As Decimal = 0
            Dim nRate As Integer = 0
            Dim dTotalCost As Decimal = 0
 
            nRate = Convert.ToInt64(lblUnits.Text.Trim())
            dCostPrice = Convert.ToDecimal(lblCostPrice.Text.Trim())
            nQuantity = Convert.ToInt64(lblQuantity.Text.Trim())
            dTotalCost = (dCostPrice * nQuantity) / nRate + dTotalCost
            dInvoice = Convert.ToDecimal(lblSellingPrice.Text.Trim())
 
 
            dProfit = dInvoice - dCostPrice
 
            lblProfit.Text = dProfit.ToString
 
            If dInvoice > 0 Then
                dMargin = (dProfit / dInvoice) * 100
                lblMargin.Text = dMargin.ToString("###,##0.0")
            Else
                lblMargin.Text = "0"
            End If
 
            pnTotalQuantity = pnTotalQuantity + nQuantity
            pdTotalInvoice = pdTotalInvoice + dInvoice
            pdTotalCost = pdTotalCost + dCostPrice
            pdTotalProfit = pdTotalProfit + dProfit
 
        ElseIf TypeOf e.Item Is GridFooterItem And e.Item.OwnerTableView.Name = "Groups" Then
 
            'Dim lblTotalFFCost As Label = e.Item.FindControl("lblTotalFFCost")
            'Dim lblTotalFFInvoice As Label = e.Item.FindControl("lblTotalFFInvoice")
            'Dim lblTotalFFProfit As Label = e.Item.FindControl("lblTotalFFProfit")
            'Dim lblTotalFFQuantity As Label = e.Item.FindControl("lblTotalFFQuantity")
 
            lblTotalFFQuantity.Text = pnTotalFFQuantity.ToString
            lblTotalFFInvoice.Text = pdTotalFFInvoice.ToString("£###,##0.00")
            lblTotalFFCost.Text = pdTotalFFCost.ToString("£###,##0.00")
            lblTotalFFProfit.Text = pdTotalFFProfit.ToString("£###,##0.00")
 
 
        ElseIf TypeOf e.Item Is GridFooterItem And e.Item.OwnerTableView.Name = "Items" Then
 
            Dim lblTotalQuantity As Label = e.Item.FindControl("lblTotalQuantity")
            Dim lblTotalInvoice As Label = e.Item.FindControl("lblTotalInvoice")
            Dim lblTotalCost As Label = e.Item.FindControl("lblTotalCost")
            Dim lblTotalProfit As Label = e.Item.FindControl("lblTotalProfit")
 
            pnTotalFFQuantity = pnTotalQuantity + pnTotalFFQuantity
            pdTotalFFInvoice = pdTotalInvoice + pdTotalFFInvoice
            pdTotalFFCost = pdTotalCost + pdTotalFFCost
            pdTotalFFProfit = pdTotalProfit + pdTotalFFProfit
 
            lblTotalQuantity.Text = pnTotalQuantity.ToString
            lblTotalInvoice.Text = pdTotalInvoice.ToString("£###,##0.00")
            lblTotalCost.Text = pdTotalCost.ToString("£###,##0.00")
            lblTotalProfit.Text = pdTotalProfit.ToString("£###,##0.00")
 
 
            ' Reset
            pdTotalCost = 0
            pnTotalQuantity = 0
            pdTotalInvoice = 0
            pnTotalQuantity = 0
 
        End If
 
 
    End Sub
0
Andrey
Telerik team
answered on 31 Jan 2012, 06:08 PM
Hi,

Try changing your template column definition as follows:

<telerik:GridTemplateColumn HeaderText="Item Name">
    <ItemTemplate>
        <asp:Label ID="lblItemName" runat="server" Text='<%# Eval("ItemName") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:TextBox ID="txtItemName" runat="server" Text='<%# Bind("ItemName") %>' MaxLength="100">
        </asp:TextBox>
        <asp:RequiredFieldValidator ID="rfvtxtItemName" runat="server" ErrorMessage="!" Display="Dynamic"
            ControlToValidate="txtItemName">
        </asp:RequiredFieldValidator>
    </EditItemTemplate>
    <ItemStyle Width="30%" />
</telerik:GridTemplateColumn>

If this does not help, please isolate the problem in a sample project and upload it on a web share service. Thus we will be able to debug/test it locally.

Greetings,
Andrey
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
0
Muhammad
Top achievements
Rank 1
answered on 01 Feb 2012, 12:44 PM
Hi,

I have uploaded that project with the project files and a database scripts. You can download that project from here. This problem still exists whenever you do a rebind after adding a group or item in a nested grid you will get the exception.

Thanks.
0
Andrey
Telerik team
answered on 03 Feb 2012, 02:03 PM
Hi,

I tested your project and noticed behavior you are observing.

You need to remove the call to the rgQuotation Rebind() method in order to successfully insert a record into the datasource. When you are using some of the internal commands of RadGrid(PerformInsert, Update, etc) RadGrid is calling internally Rebind operation of the respective TableView object. So, you do not need to call it explicitly.

Additionally, please note that it is not recommended to use the ItemCommand event to perform manual CRUD operations. You should use the respective command events(OnInserCommand, OnUpdateCommand, OnDeleteCommand) for this purpose, like described here.

Give these suggestions a try and check whether the issue is resolved.

Regards,
Andrey
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
Muhammad
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Muhammad
Top achievements
Rank 1
Share this question
or