Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > DataFormatString questions...

Reply
Thread Tools

DataFormatString questions...

 
 
Michael Tanner
Guest
Posts: n/a
 
      11-10-2003
I have 2 formatting cases that I need to handle:

Case 1: an eight digit account number stored in database as such - 12345678
I need to display this in a boundcolumn as such - 1234-5678

Case 2: a number is stored in the database as such - 42
I need to display this in a boundcolumn as such - 0000042

Can I use the DataFormatString property to accomplish these 2 cases and how?

Thanks,
Mike


 
Reply With Quote
 
 
 
 
Aaron Weiker
Guest
Posts: n/a
 
      11-14-2003
Mike,
Here is a brief sample that you can put into an ASP.NET page and it will
demonstrate on how to do what you wanted. For more information look up
String.Format() in the MSDN library.

http://msdn.microsoft.com/library/de...n-us/cpref/htm
l/frlrfsystemstringclassformattopic2.asp

<!-- ################################# -->

<%@ Page Language="C#" Debug="True" %>
<script runat="server">
private void Page_Load(object sender, EventArgs e) {
if (original.Text.Length > 0) {
result1.Text = String.Format("{0:000000##}", int.Parse(original.Text));
result2.Text = String.Format("{0:0000-0000}", int.Parse(original.Text));
}

}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:textbox id="original" runat="server" /> <br />
<asp:label id="result1" runat="server" /> <br />
<asp:label id="result2" runat="server" /> <br />
<asp:button id="transform" runat="server" text="transform" />
</form>
</body>
</html>
<!-- ################################# -->

Aaron Weiker
http://aaronweiker.com/posts/174.aspx

On Mon, 10 Nov 2003 15:31:54 -0500, Michael Tanner wrote:

> I have 2 formatting cases that I need to handle:
>
> Case 1: an eight digit account number stored in database as such - 12345678
> I need to display this in a boundcolumn as such - 1234-5678
>
> Case 2: a number is stored in the database as such - 42
> I need to display this in a boundcolumn as such - 0000042
>
> Can I use the DataFormatString property to accomplish these 2 cases and how?
>
> Thanks,
> Mike

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I display 221 seconds as 03:41 using DataFormatString Tarren ASP .Net 7 01-20-2005 11:54 AM
DataFormatString Kenny ASP .Net 1 12-31-2004 03:24 PM
How to use DataFormatString? Kenny ASP .Net 3 12-31-2004 05:20 AM
Re: DataFormatString="{0:C}" doesn't show currency victor nguyen ASP .Net 1 09-10-2004 11:06 PM
DataFormatString Doesn't Work frank ASP .Net 1 09-05-2003 04:18 PM



Advertisments