tfowler Posted November 13, 2006 Posted November 13, 2006 I have no idea why my GridView fields are ignoring my data format string. As you can see, I've tried both a TemplateField and a BoundField, and neither will show the data as formatted: [size=2][color=#0000ff]<[/color][/size][size=2][color=#a31515]form [/color][/size][size=2][color=#ff0000]id[/color][/size][size=2][color=#0000ff]="form1" [/color][/size][size=2][color=#ff0000]runat[/color][/size][size=2][color=#0000ff]="server">[/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]asp[/color][/size][size=2][color=#0000ff]:[/color][/size][size=2][color=#a31515]GridView [/color][/size][size=2][color=#ff0000]ID[/color][/size][size=2][color=#0000ff]="gvWafer" [/color][/size][size=2][color=#ff0000]runat[/color][/size][size=2][color=#0000ff]="server" [/color][/size][size=2][color=#ff0000]Font-Size[/color][/size][size=2][color=#0000ff]="XX-Small"[/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#ff0000] AutoGenerateColumns[/color][/size][size=2][color=#0000ff]="False">[/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]Columns[/color][/size][size=2][color=#0000ff]>[/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]asp[/color][/size][size=2][color=#0000ff]:[/color][/size][size=2][color=#a31515]TemplateField [/color][/size][size=2][color=#ff0000]HeaderText[/color][/size][size=2][color=#0000ff]="13">[/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]ItemTemplate[/color][/size][size=2][color=#0000ff]>[/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]asp[/color][/size][size=2][color=#0000ff]:[/color][/size][size=2][color=#a31515]Label[/color][/size][size=2][color=#ff0000]ID[/color][/size][size=2][color=#0000ff]="lblCol13"[/color][/size][size=2][color=#ff0000]runat[/color][/size][size=2][color=#0000ff]="server"[/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#ff0000] Text[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]<%# bind("col13", "{0:n0}") %>[/size][size=2][color=#0000ff]>[/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff] </[/color][/size][size=2][color=#a31515]asp[/color][/size][size=2][color=#0000ff]:[/color][/size][size=2][color=#a31515]Label[/color][/size][size=2][color=#0000ff]>[/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff] </[/color][/size][size=2][color=#a31515]ItemTemplate[/color][/size][size=2][color=#0000ff]>[/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff] </[/color][/size][size=2][color=#a31515]asp[/color][/size][size=2][color=#0000ff]:[/color][/size][size=2][color=#a31515]TemplateField[/color][/size][size=2][color=#0000ff]>[/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]asp[/color][/size][size=2][color=#0000ff]:[/color][/size][size=2][color=#a31515]BoundField[/color][/size][size=2][color=#ff0000]DataField[/color][/size][size=2][color=#0000ff]="col14"[/color][/size][size=2][color=#ff0000]DataFormatString[/color][/size][size=2][color=#0000ff]="{0:n0}"[/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#ff0000] HeaderText[/color][/size][size=2][color=#0000ff]="14"[/color][/size][size=2][color=#ff0000]HtmlEncode[/color][/size][size=2][color=#0000ff]="False"[/color][/size][size=2][color=#0000ff]/>[/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff] </[/color][/size][size=2][color=#a31515]Columns[/color][/size][size=2][color=#0000ff]>[/color][/size][/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff] </[/color][/size][size=2][color=#a31515]asp[/color][/size][size=2][color=#0000ff]:[/color][/size][size=2][color=#a31515]GridView[/color][/size][size=2][color=#0000ff]>[/color][/size][/color][/size][/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]form[/color][/size][size=2][color=#0000ff]> [/color][/size][/color][/size][/color][/size][/color][/size] The DataSet is filled from the following XML file: [size=2][color=#0000ff]<?[/color][/size][size=2][color=#a31515]xml[/color][/size][size=2][color=#ff0000]version[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]1.0[/color][/size][size=2]"[/size][size=2][color=#ff0000]standalone[/color][/size][size=2][color=#0000ff]=[/color][/size][size=2]"[/size][size=2][color=#0000ff]yes[/color][/size][size=2]"[/size][size=2][color=#0000ff]?>[/color][/size] [size=2][color=#0000ff]<[/color][/size][size=2][color=#a31515]WaferMap[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff]<[/color][/size][size=2][color=#a31515]Map[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]col13[/color][/size][size=2][color=#0000ff]>[/color][/size][size=2]53.0744[/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]col13[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]col14[/color][/size][size=2][color=#0000ff]>[/color][/size][size=2]56.0382[/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]col14[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]col15[/color][/size][size=2][color=#0000ff]>[/color][/size][size=2]59.3042[/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]col15[/color][/size][size=2][color=#0000ff]> [size=2][/size] <[/color][/size][size=2][color=#a31515]col16[/color][/size][size=2][color=#0000ff]>[/color][/size][size=2]63.2966[/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]col16[/color][/size][size=2][color=#0000ff]> [/color][/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]Map[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff]<[/color][/size][size=2][color=#a31515]Map[/color][/size][size=2][color=#0000ff]>[/color][/size][/color][/size] [size=2][color=#0000ff][size=2][color=#0000ff] <[/color][/size][size=2][color=#a31515]col13[/color][/size][size=2][color=#0000ff]>[/color][/size][size=2][color=#000000]54.6394[/color][/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]col13[/color][/size][size=2][color=#0000ff]> [size=2][color=#0000ff][size=2][color=#0000ff][/color][/size][/color][/size] <[/color][/size][size=2][color=#a31515]col14[/color][/size][size=2][color=#0000ff]>[/color][/size][size=2][color=#000000]57.8624[/color][/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]col14[/color][/size][size=2][color=#0000ff]> [size=2][color=#0000ff][size=2][color=#0000ff][/color][/size][/color][/size] <[/color][/size][size=2][color=#a31515]col15[/color][/size][size=2][color=#0000ff]>[/color][/size][size=2][color=#000000]61.3318[/color][/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]col15[/color][/size][size=2][color=#0000ff]> [size=2][color=#0000ff][size=2][color=#0000ff][/color][/size][/color][/size] <[/color][/size][size=2][color=#a31515]col16[/color][/size][size=2][color=#0000ff]>[/color][/size][size=2][color=#000000]65.6252[/color][/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]col16[/color][/size][size=2][color=#0000ff]> [/color][/size][size=2][color=#0000ff]</[/color][/size][size=2][color=#a31515]Map[/color][/size][size=2][color=#0000ff]>[/color][/size] [size=2][color=#0000ff] :[/color][/size] [size=2][color=#0000ff] : [/color][/size][/color][/size][size=2][color=#0000ff]<[/color][/size][size=2][color=#a31515]WaferMap[/color][/size][size=2][color=#0000ff]>[/color][/size] Thanks for any help, Todd Quote
MrPaul Posted November 13, 2006 Posted November 13, 2006 Bad format string? If the data is being displayed, but not formatted correctly, then obviously the fields are being bound correctly, but there may be a problem with the actual format string. I expect the curly braces notation is unnecessary here, and would recommend you try just "n0". Good luck :cool: Quote Never trouble another for what you can do for yourself.
tfowler Posted November 13, 2006 Author Posted November 13, 2006 You are correct that the data is being displayed, but not formatted. Thanks for your suggestion, but using DataFormatString="n0", gives me exactly that...the "n0" string is displayed in all of the cells in the column. This is extremely annoying. Formatting data in a grid column should be a simple request. I know I've had this work in the past. I did install the Visual Studio 2005 SP1 Beta...I wonder if it has anything to do with it? I doubt it, but I haven't been able to find anything else that would cause the problem. Thanks, Todd Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.