Leading Zeros in GridView

I have a number coming out of a database  (between 1 and around 900), but it needs to have leading zeros up to four digits (1 becomes 0001, 900 becomes 0900).

I found an answer to another question that would add the leading zeros by transforming the string, but as I am adding this into a gridview using the 'Bind' argument (well so far), I can't use the solution.


    <asp:Label ID="Label_1" runat="server" Text='<%#Bind("Value")%>'></asp:Label> 


I did try <%#Bind("Value", "{0:####}")%>, But that doesn't do the trick.

Any ideas?


Read More


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s