This question is locked. New answers and comments are not allowed.
I have a GridViewMaskedTextBoxColumn control inside gridview binded to datasource via DataMemberBinding property. It's for credit card expiration date in ##/## format. When committing save, it only reads the numeric value and omit the "/" character. How do I make it return value including this character?
Also, how do I do insert? I read this thread http://www.telerik.com/community/forums/silverlight/gridview/insert-new-row-sample-where.aspx but pressing the "Insert" key on my keyboard after the grdiview get focus doesn't do anything. The gridview itemsource is bind to a SQL server view model
Also, how do I do insert? I read this thread http://www.telerik.com/community/forums/silverlight/gridview/insert-new-row-sample-where.aspx but pressing the "Insert" key on my keyboard after the grdiview get focus doesn't do anything. The gridview itemsource is bind to a SQL server view model
5 Answers, 1 is accepted
0
Hi Alex Wu,
On your first Question :
Unfortunately the GridViewMaskedTextBoxColumn does not support such scenarios. It will always return the value with the mask stripped .
The solution is to use a regular GridViewDataColumn with a modified CellEditTemplate.
You should place a RadMaskedTextBox into the CellEditTemplate and use the MaskedText property for binding instead of the Value property.
For reference on setting the CellEditTemplate property please have a look at the xAML in the following online example.
In case you have troubles implementing this- let me know and I will prepare a small sample for you .
About your second question:
When RadGridView tries to show the new row it needs to create a new instance of the underlying business object. It seems that for some reason it it fails to create the object or add it to the collection .
To make the grid able to create a new business object it should have a default ( parameterless) constructor.
If that is not applicable you should take care of creating a new instance within the AddingNewDataItem event handler as demonstrated this help topic.
Kind regards,
Pavel Pavlov
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.
On your first Question :
Unfortunately the GridViewMaskedTextBoxColumn does not support such scenarios. It will always return the value with the mask stripped .
The solution is to use a regular GridViewDataColumn with a modified CellEditTemplate.
You should place a RadMaskedTextBox into the CellEditTemplate and use the MaskedText property for binding instead of the Value property.
For reference on setting the CellEditTemplate property please have a look at the xAML in the following online example.
In case you have troubles implementing this- let me know and I will prepare a small sample for you .
About your second question:
When RadGridView tries to show the new row it needs to create a new instance of the underlying business object. It seems that for some reason it it fails to create the object or add it to the collection .
To make the grid able to create a new business object it should have a default ( parameterless) constructor.
If that is not applicable you should take care of creating a new instance within the AddingNewDataItem event handler as demonstrated this help topic.
Kind regards,
Pavel Pavlov
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.
0
Alex Wu
Top achievements
Rank 1
answered on 30 Dec 2009, 12:49 AM
Thank you for the reply.
"To make the grid able to create a new business object it should have a default ( parameterless) constructor. "
Can you please elaborate what you mean by that?
"To make the grid able to create a new business object it should have a default ( parameterless) constructor. "
Can you please elaborate what you mean by that?
0
Hello Alex Wu,
"To make the grid able to create a new business object it should have a default ( parameterless) constructor. "
In other words this means that when GridView creates an empty instance of your bussines. Thus, it needs constructor with signature:
If you have created constructors that accept parameters and not provide a parameterless constructor the GridView will not be able to create new instance of an object and you will need to do this manually using the AddingNewDataItem event.
Hope this helps.
Best wishes,
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.
"To make the grid able to create a new business object it should have a default ( parameterless) constructor. "
In other words this means that when GridView creates an empty instance of your bussines. Thus, it needs constructor with signature:
public BusinessObject()If you have created constructors that accept parameters and not provide a parameterless constructor the GridView will not be able to create new instance of an object and you will need to do this manually using the AddingNewDataItem event.
Hope this helps.
Best wishes,
Tsvyatko
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.
0
Alex Wu
Top achievements
Rank 1
answered on 31 Dec 2009, 01:53 AM
I am using RIA so the object returned is EntitySet type. I think this is the problem because if I change the type to List then it works, but obviously I can't commit the change back to the database if I use a list. How can I handle it in this case? Is handling it in the AddingNewDataItem event handler the only choice I have now?
0
Accepted
Hello Alex Wu,
RadGridView cannot create new item without parameter less (default) constructor, so if you want to add new item through RadGridView you should handle AddingNewDataItem event. Another option is to add new empty item in the data source directly (you have to rebind grid if data source does not implement INotifyCollectionChange interface).
Best wishes,
Nedyalko Nikolov
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.
RadGridView cannot create new item without parameter less (default) constructor, so if you want to add new item through RadGridView you should handle AddingNewDataItem event. Another option is to add new empty item in the data source directly (you have to rebind grid if data source does not implement INotifyCollectionChange interface).
Best wishes,
Nedyalko Nikolov
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.