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

Mask not working in GridMaskedColumn

2 Answers 219 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manikandan Balasubramaniyan
Top achievements
Rank 1
Manikandan Balasubramaniyan asked on 12 Jan 2011, 06:20 PM
Hi,
I added the below code for masking a column. The column has to display 9-digit number in this form ####-#####
But the column is displayed as  123456789 instead of  1234-56789

<telerik:RadGrid ID="rg_submitted_requests" runat="server" AllowPaging="True" AutoGenerateColumns="False" AllowSorting="True" GridLines="Both" CellPadding="0">
   <MasterTableView  AutoGenerateColumns="false">
    <Columns>
        <telerik:GridMaskedColumn Mask="####-#####" HeaderText="PAF #" DataField="PAF_NUMBER">                        
        </telerik:GridMaskedColumn>
    </Columns>
   </MasterTableView>
</telerik:RadGrid>

Please let me know if there any issues with the above code.

Appreciate your help,
Mani

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 13 Jan 2011, 07:52 AM
Hello Manikandan,

GridMaskedColumn displays exactly like an ordinary GridBoundColumn in regular mode and in edit mode,  it displays a RadMaskedTextBox control. Therefor you can use any of the following approaches to formatting your data values before they are displayed in grid cells.

ASPX:
<telerik:GridMaskedColumn Mask="####-#####" HeaderText="PAF #" DataField="PAF_NUMBER"
    DataFormatString="{0:####-#####}" UniqueName="PAF_NUMBER">
</telerik:GridMaskedColumn>

c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = (GridDataItem)e.Item;
        string originalText = dataItem["PAF_NUMBER"].Text;
        //format originalText here
        dataItem["PAF_NUMBER"].Text = originalText;
    }
}

Thanks,
Princy.
0
Eva
Top achievements
Rank 1
answered on 08 Sep 2011, 10:12 PM
Hi Princy,

I am having the same issue.

Could you please tell me how to format  SSN(Mask="###-##-####") from ItemDatabound.

Thanks.
Eva
Tags
Grid
Asked by
Manikandan Balasubramaniyan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Eva
Top achievements
Rank 1
Share this question
or