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

DataFormatString . How to save raw data?

2 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zenute Marins
Top achievements
Rank 1
Zenute Marins asked on 16 Oct 2011, 01:35 AM
Hi guys.

I have a masked column with dataformatstring set to {0:##.###.###/####-##} and mask set to ##.###.###/####-##.The grid displays and edits the column as expected.
The problem is that I dont´t want to save the format characters to the database. I want to save the raw data 34889238000131 and not the formatted data 34.889.238/0001-31. 
What´s the best way to go in this case?

Thank you.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Oct 2011, 09:07 AM
Hello Zenute Marins,

I am not sure that which method you are using to insert the items. When I tried with  automatic insertion I also faced the same. And was able to overcome this by accessing the MaskedTextBox value and pass it as a session variable.

C#:
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
   GridEditableItem editedItem = e.Item as GridEditableItem;
   string FirstName = (editedItem["mask"].Controls[0] as RadMaskedTextBox).Text; 
   Session["mask1"]=FirstName;
         
 }

ASPX:
<InsertParameters >
<asp:SessionParameter Name="mask1" SessionField="mask1" />
</InsertParameters>

Thanks,
Princy.
0
Zenute Marins
Top achievements
Rank 1
answered on 19 Oct 2011, 01:40 PM
Princy,
I decided to use a template column with a radmaskedtextbox and it worked.
Thank you for your help.
Tags
Grid
Asked by
Zenute Marins
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Zenute Marins
Top achievements
Rank 1
Share this question
or