Sys.WebForms.PageRequestManagerServerErrorException: An item with the same key has already been added.
If we are commenting the grid calculated columns paging is working fine.
Thanks
12 Answers, 1 is accepted
Could you please elaborate a bit more on your scenario? Is it possible to have column with duplicate DataField? If you could share your grid declaration and any connected server code could help us provide a resolution for you.
All the best,
Pavlina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Please find the code for the Telerik grid.
Even after doing custom paging and custom sorting, I am getting the same error.
Default.aspx
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<telerik:RadGrid ID="RadGrid1" runat="server" EnableEmbeddedSkins="true" AllowPaging="True"
AllowSorting="True" PageSize="2" GridLines="None" EnableLinqExpressions="false">
<MasterTableView AutoGenerateColumns="False" AllowNaturalSort="false">
<Columns>
<telerik:GridBoundColumn HeaderText="Account" UniqueName="AccountNumber" DataField="AccountNumber"
AllowSorting="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="TotalShares" DataField="TotalShares" HeaderText="Total No. of Shares"
DataType="System.Double">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="MarketValue" DataField="MarketValue" HeaderText="Market Value"
DataType="System.Double">
</telerik:GridBoundColumn>
<telerik:GridCalculatedColumn HeaderText="Total Price" DataFields="TotalShares, MarketValue"
Expression="{0}*{1}" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
Default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Page.Title = "RAD prototype";
List<Account> accList = new List<Account>();
Account acc = new Account();
acc.AccountNumber = 123;
acc.MarketValue = 120.32;
acc.TotalShares = 100;
accList.Add(acc);
Account acc2 = new Account();
acc2.AccountNumber = 123;
acc2.MarketValue = 100.1;
acc2.TotalShares = 12;
accList.Add(acc2);
Account acc3 = new Account();
acc3.AccountNumber = 567;
acc3.MarketValue = 2003.12;
acc3.TotalShares = 91;
accList.Add(acc3);
Account acc4 = new Account();
acc4.AccountNumber = 567;
acc4.MarketValue = 102.3;
acc4.TotalShares = 43;
accList.Add(acc4);
Account acc5 = new Account();
acc5.AccountNumber = 912;
acc5.MarketValue = 102.3;
acc5.TotalShares = 43;
accList.Add(acc5);
Session["AccountValue"] = accList;
RadGrid1.DataSource = Session["AccountValue"];
RadGrid1.DataBind();
}
Account.cs
public class Account
{
private long _accountNumber;
private double _TotalShares;
private double _MarketValue;
public double TotalShares
{
get
{
return _TotalShares;
}
set
{
_TotalShares = value;
}
}
public double MarketValue
{
get
{
return _MarketValue;
}
set
{
_MarketValue = value;
}
}
public long AccountNumber
{
get
{
return _accountNumber;
}
set
{
_accountNumber = value;
}
}
}
But I have noticed that you are using Simple-DataBinding techniques(calling DataBind()). I would suggest you to use AdvanceDataBinding techniques. Try populating the Grid in the NeedDataSource event. Go through the following articles for getting more details about AdvanceDataBinding techniques.
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/grdadvanceddatabinding.html
Best wishes,
Pavlina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
At this point in order to progress in the resolution of this matter I will ask you to open a formal support ticket and send us a simple working project with reproduced this erroneous behavior. Thus we could do our best to help you further in resolving it.
Looking forward for your reply.
Kind regards,
Pavlina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I want to apply some string formatting instead of Calculation using two datafields. I can't use Templete column as I have to display same formated data in Google kind of filtering control also.
I am using two datafiled's - Date and User Count. I have to display column like dd-MMM-YYYY(User Count)
so my column data will be
12-May-2010(10)
25-Jan-2010 (10)
12-May-2010(10)
Now when user click on Filtering control(Google style) I need to dispaly same formated data in google dropdown list so user can select and filter will work.
You can embed any content inside a RadComboBox template, including HTML markup and ASP.NET server controls, as well as other third party controls. Please refer to the following online example which demonstrates how to use the combobox templates:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/templates/defaultcs.aspx
Give it a try and let me know if it works for you.
Best wishes,
Pavlina
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.
Thanks for the quick replay.
Well, still I am not able to achieve the task.
Let me make it simple. I have Datatable with datatime field and i want to display date in dd-MMM-yyyy formate in my radgrid and it allows user to filter using google style filtering.
Ex. 10-July-2010
In my datatable datawould be 07/10/2010 10:45:10AM
Please refer to the following forum thread which elaborates on this subject and see if it helps to achieve your goal:
http://www.telerik.com/community/forums/aspnet-ajax/grid/filtertemplate-with-date-and-time-filter.aspx
Best wishes,
Pavlina
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.
Hi Kishan,
I tried to execute your example. But I'd like to sum the 2 field and I'd like to avoid an error if one of the 2 fields is empty.
So I modified the code as following:
<telerik:GridCalculatedColumn HeaderText="Total Price" DataFields="TotalShares, MarketValue"
Expression="(({0} == null) ? 0 : {0}) + (({1} == null) ? 0 : {1})" />
But when run the code I have this error on RadGrid1.DataBind() :
"Syntax error: Missing operand before '=' operator."
I don't know hot to solve this problem.
Someone can help me?
Thanks
Attached you can find a sample project where one of the columns has null values and the expression you provided is working without error. Give it a try and see what is the difference in your case.
Regards,
Pavlina
Telerik