I've read other posts on the forums where people have received this error: "An Item with the same key has already been added".
In one post you said it was fixed, but I'm using the latest version 3.1125 for .NET 2.0 and I receive this error only when the CalculatedColumn is being used and I click on the Delete button.
My RadGrid is set up like this:
And my DeleteCommand code looks something like this:
So in my delete command I just delete the selected Expenditure from the database and then force the grid to rebind its results.
I know its the calculated column because when I remove it the problem goes away. So I'm guessing this bug still exists or I'm doing something wrong.
In one post you said it was fixed, but I'm using the latest version 3.1125 for .NET 2.0 and I receive this error only when the CalculatedColumn is being used and I click on the Delete button.
My RadGrid is set up like this:
<telerik:RadGrid ID="grdExpenditure" runat="server" AutoGenerateColumns="False" Width="100%" |
EnableEmbeddedSkins="False" PageSize="20" VirtualItemCount="20" Height="300px" |
BackColor="#ACBCCC" ImagesPath="~/CSS/Grid" CssClass="SearchGrid"> |
<MasterTableView AllowPaging="True" AllowSorting="True" ShowHeadersWhenNoRecords="True" |
DataKeyNames="Expenditure_ID" TableLayout="Fixed"> |
<Columns> |
<telerik:GridHyperLinkColumn DataNavigateUrlFields="Expenditure_ID" DataNavigateUrlFormatString="cClient_ExpenditureEdit.aspx?Expend_ID={0}" |
UniqueName="Select" Text="<img src='../images/edit.gif' style='border-style: none' alt='Select' />"> |
<ItemStyle Width="2%" HorizontalAlign="Center" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle Width="2%" HorizontalAlign="Center" /> |
</telerik:GridHyperLinkColumn> |
<telerik:GridBoundColumn DataField="NameAbbr" HeaderText="Prop." SortExpression="NameAbbr"> |
<ItemStyle HorizontalAlign="Left" Width="4%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Left" Width="4%" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description"> |
<ItemStyle HorizontalAlign="Left" Width="16%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Left" Width="16%" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Item" HeaderText="Expense Item" SortExpression="Item"> |
<ItemStyle HorizontalAlign="Left" Width="10%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Left" Width="10%" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Category" HeaderText="Expense Category" SortExpression="Category"> |
<ItemStyle HorizontalAlign="Left" Width="16%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Left" Width="16%" /> |
</telerik:GridBoundColumn> |
<telerik:GridCheckBoxColumn DataField="IsCapitalExpense" HeaderText="Capital Exp" |
SortExpression="IsCapitalExpense"> |
<ItemStyle HorizontalAlign="Center" Width="5%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Center" Width="5%" /> |
</telerik:GridCheckBoxColumn> |
<telerik:GridBoundColumn DataField="VendorName" HeaderText="Vendor" SortExpression="VendorName"> |
<ItemStyle HorizontalAlign="Left" Width="10%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Left" Width="10%" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="TransactionDate" DataFormatString="{0:MMM. dd yyyy}" |
HeaderText="Transaction Date" SortExpression="TransactionDate"> |
<ItemStyle HorizontalAlign="Center" Width="7%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Center" Width="7%" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="TaxAmount" DataFormatString="{0:c}" HeaderText="Taxes" |
SortExpression="TaxAmount"> |
<ItemStyle HorizontalAlign="Right" Width="9%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Right" Width="9%" /> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="TotalAmount" DataFormatString="{0:c}" HeaderText="Taxable Amount" |
SortExpression="TotalAmount"> |
<ItemStyle HorizontalAlign="Right" Width="9%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Right" Width="9%" /> |
</telerik:GridBoundColumn> |
<telerik:GridCalculatedColumn Aggregate="Sum" Expression="{0}+{1}" DataType="System.Decimal" DataFields="TotalAmount,TaxAmount" HeaderText="Total" DataFormatString="{0:c}" |
> |
<ItemStyle HorizontalAlign="Right" Width="9%" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle HorizontalAlign="Right" Width="9%" /> |
</telerik:GridCalculatedColumn> |
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ImageUrl="~/images/delete.gif" |
ConfirmText="Are You Sure You Want To Delete The Selected Expenditure?" ConfirmTitle="Delete Expenditure?"> |
<ItemStyle Width="3%" HorizontalAlign="Center" BorderWidth="1px" BorderColor="#000000" |
BorderStyle="Solid" /> |
<HeaderStyle Width="3%" HorizontalAlign="Center" /> |
</telerik:GridButtonColumn> |
</Columns> |
<AlternatingItemStyle BackColor="#ACBCCC" CssClass="mainInvoicingTextBlue " /> |
<ItemStyle BackColor="#FFFFFF" CssClass="mainInvoicingTextBlue" /> |
<HeaderStyle BackColor="#ACBCCC" CssClass="mainInvoicingTextBlue linkGoRentProBlue" |
Height="20px" BorderWidth="1px" BorderColor="#000000" BorderStyle="Solid" /> |
<PagerStyle Mode="NextPrevAndNumeric" BackColor="#394D6B" Font-Bold="True" CssClass="mainInvoicingTextWhite linkGoRentProWhite" |
BorderWidth="1px" BorderColor="#000000" BorderStyle="Solid" PagerTextFormat="Page: {4} Total Records: {5}" |
ShowPagerText="True" AlwaysVisible="True" /> |
<FooterStyle BackColor="#394D6B" BorderWidth="1px" BorderColor="#000000" BorderStyle="Solid" |
CssClass="mainInvoicingTextWhite" Font-Bold="True" /> |
</MasterTableView> |
<ClientSettings> |
<Scrolling UseStaticHeaders="True" AllowScroll="True" SaveScrollPosition="False" /> |
</ClientSettings> |
</telerik:RadGrid> |
And my DeleteCommand code looks something like this:
Protected Sub grdExpenditure_DeleteCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdExpenditure.DeleteCommand |
Try |
'hold expenditure id |
Dim Expenditure_ID As Integer = Me.grdExpenditure.MasterTableView.DataKeyValues(e.Item.ItemIndex)("Expenditure_ID") |
'delete the expenditure |
If DeleteExpenditure(Expenditure_ID) > 0 Then |
'alert success |
'rebind the grid |
Me.grdExpenditure.Rebind() |
Else |
'alert failure |
End If |
Catch ex As Exception |
End Try |
End Sub |
So in my delete command I just delete the selected Expenditure from the database and then force the grid to rebind its results.
I know its the calculated column because when I remove it the problem goes away. So I'm guessing this bug still exists or I'm doing something wrong.