Hello,
I have a
public ObservableCollection<KeyValuePair<decimal, string>> myEntries { get; set;}
bound to my radGridView:
ItemsSource="{Binding Path=myEntries, Mode=TwoWay}"
and have the <CanUserInsertRows="True"> set.
However, I cannot add any entry: Not by clicking the left "+" for "Click here to add any item" nor by calling "BeginInsert();".
When I remove "ItemSource=", I at least can see that now there is space for an empty row. So is something wrong with my binding? I can, by the way, delete items from the collection by pressing "del". But I cannot add any.
Is there a problem with the 'public ObservableCollection<KeyValuePair<decimal, string>> myEntries { get; set;}'?
Can somebody tell me why not even the empty row appears when clicking on "Click here to add any item"?
Thank you!
I have a
public ObservableCollection<KeyValuePair<decimal, string>> myEntries { get; set;}
bound to my radGridView:
ItemsSource="{Binding Path=myEntries, Mode=TwoWay}"
and have the <CanUserInsertRows="True"> set.
However, I cannot add any entry: Not by clicking the left "+" for "Click here to add any item" nor by calling "BeginInsert();".
When I remove "ItemSource=", I at least can see that now there is space for an empty row. So is something wrong with my binding? I can, by the way, delete items from the collection by pressing "del". But I cannot add any.
Is there a problem with the 'public ObservableCollection<KeyValuePair<decimal, string>> myEntries { get; set;}'?
Can somebody tell me why not even the empty row appears when clicking on "Click here to add any item"?
Thank you!
5 Answers, 1 is accepted
0
Hi Lars,
The Key and the Value properties of the KeyValuePair have only get property, so you cannot edit the values in the columns that are bound to them.
If you have any further questions, please do not hesitate to contact us. All the best,
Didie
the Telerik team
You cannot add any entry: Not by clicking the left "+" for "Click here to add any item" nor by calling "BeginInsert();", because the RadGridView does not know how to create the new object of type KeyValuePair<decimal, string>. This is due to the fact that KeyValuePair<> does not have a default constructor.
In order to add new entries you may subscribe to the AddingNewDataItem of the GridView and initialize the NewObject there:
AddingNewDataItem="myEntriesGrid_AddingNewDataItem"
private
void
myEntriesGrid_AddingNewDataItem(
object
sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
{
e.NewObject =
new
KeyValuePair<
decimal
,
string
>(50,
"sample"
);
}
The Key and the Value properties of the KeyValuePair have only get property, so you cannot edit the values in the columns that are bound to them.
If you have any further questions, please do not hesitate to contact us. All the best,
Didie
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
0

Lars
Top achievements
Rank 1
answered on 03 Jun 2011, 08:34 AM
Yes, that helped. Thank you very much.
Lars.
Lars.
0

Walkingstar
Top achievements
Rank 1
answered on 13 Jun 2011, 09:20 PM
New to Using telerik controls.
I did not understand how to use KeyValuePair in this instance. Can you provide more information on how to Insert new records on-click of "Click here to add any item" button in the RadGrid.
Thanks.
I did not understand how to use KeyValuePair in this instance. Can you provide more information on how to Insert new records on-click of "Click here to add any item" button in the RadGrid.
Thanks.
0
Hi Walkingstar,
Didie
the Telerik team
The Key and the Value properties of the KeyValuePair have only get property, therefore it does not allow you to add and edit Keys and Values in the columns that are bound to them.
You may insert new rows directly using a whole new KeyValuePair<> object like shown in my previous post.
Didie
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
0

Walkingstar
Top achievements
Rank 1
answered on 14 Jun 2011, 05:09 PM
Thanks Didi.