ASP .NET Formatting a bound field in a gridview control

44 views
Skip to first unread message

sandy

unread,
Feb 2, 2007, 11:29:46 AM2/2/07
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
I need to display the SSN, which is a bound field; however, I need to
format the prefix of the string with asterisks followed by the last
four digits of the field. Also, I need to be able to sort on the
field. How do I do that? I can't seem to get the DataFormatString
property to work. I thought about adding another column as a template
field/label and hiding the bound field. But when I hide the field, I
cannot access the hidden field in the code behind. What am I doing
wrong? Sample code in VB would be much appreciated.

dan

unread,
Feb 6, 2007, 4:52:19 PM2/6/07
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
if you are using .net 2.0 format the string in initalize_row event. I
think in 1.0 it was data bound event. Capture the string and set the
text
string temp = (string)e.Row.Cells[1];
e.Row.Cells[1] = "****" + temp.SubString(5,8)

somthing along these lines. Sorry, I used C#. By the way wether hidden
or not you should be able to access the field. try
e.row.fincontrol("controlname")

- Nandan Madupu

Reply all
Reply to author
Forward
0 new messages