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

GridMaskedColumn

4 Answers 182 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Borneman
Top achievements
Rank 1
David Borneman asked on 01 Feb 2008, 05:41 PM

I am using the following GridMaskedColumn in my grid. It works great if I want to store my phone numbers in the DB with the special characters but I don't. So I'm stripping the extra characters of the mask off before inserting so a phone is stored as 9999999999 rather than (999) 999-9999.

My first question is why does this write the mask to the database in the first place? A mask is a mask - it should write what's IN the mask and not the mask itself.

Second question - How can I get DataFormatString to work when this column is displayed. Currently my phones are displayed literally as (###) ###-####" . The DataFormatString is not working.

<
telerik:GridMaskedColumn Mask="(###) ###-####"
UniqueName="Phone"
HeaderText="Phone"
DataField="Phone"
CurrentFilterFunction="EqualTo"
DataFormatString="(###) ###-####"
FilterListOptions="VaryByDataType"
ForceExtractValue="None">
<ItemStyle Width="100px" />
</telerik:GridMaskedColumn>

4 Answers, 1 is accepted

Sort by
0
David Borneman
Top achievements
Rank 1
answered on 02 Feb 2008, 05:54 AM
Nevermind I fixed this myself. I had the format wrong for one thing and I brought the phone datafield in as a cast to int so the format would work on it. I still don't think the mask should have to be stripped from the value before you can insert to the DB though.
0
Nicolo
Top achievements
Rank 1
answered on 05 Feb 2008, 12:57 PM
Hello David
You wrote it is necessary to cast into int for DataFormatString working. How did you it and how does your GridMaskedColumn definition look now?
Thanks
0
David Borneman
Top achievements
Rank 1
answered on 05 Feb 2008, 03:39 PM

<

asp:SqlDataSource runat="server"
            ID="sdsPhones" 
            ConnectionString="<%$ ConnectionStrings:ECMConnection %>"
            SelectCommand="SELECT p.PhoneID, p.PartyID, CAST(p.Phone AS bigint)as Phone, p.Extension, p.Description, t.PhoneTypeName FROM Phone p, PhoneType t WHERE p.PartyID=@PartyID AND p.PhoneTypeID = t.PhoneTypeID">
            <SelectParameters>
                <asp:SessionParameter Name="PartyID" SessionField="PartyID" />
            </SelectParameters>
</asp:SqlDataSource>


<

telerik:radmaskedtextbox runat="server"
            
id="newPhone" 
            
PromptChar="_" 
            
Skin="Default" 
            
Mask="(###) ###-####">
</telerik:radmaskedtextbox>

You have to cast the phone number as a bigint in order for the mask to work.

0
Nicolo
Top achievements
Rank 1
answered on 05 Feb 2008, 09:56 PM
Thanks!
Tags
Grid
Asked by
David Borneman
Top achievements
Rank 1
Answers by
David Borneman
Top achievements
Rank 1
Nicolo
Top achievements
Rank 1
Share this question
or