I have the following code in the columns section of my GridView:
<Columns>
<asp:boundfield datafield="Nominal-Anual" HeaderText="Nominal anual"/>
<asp:boundfield datafield="Anual" headertext="Anual" sortexpression="Anual" />
<asp:boundfield datafield="Semestral" headertext="Semestral" DataFormatString="{0:0.00}" />
<asp:BoundField DataField="Trimestral" HeaderText="Semestral" HtmlEncode="false" DataFormatString="{0:00.0000}" />
<asp:BoundField DataField="Mensual" HeaderText="Mensual" />
</Columns>
This gridview is feed from a datatable wich all datacolumns are of string type.
My problem is that the DataFormatString is not being applied and i dont know why.
Im getting a lots of decimals in all columns included the ones with dataformatstrings.
What could be happening?
Thanks in advance.
Best Regards.
Jose
Try
I’ve seen this happening because (and correct me if I’m wrong) the field value is HtmlEncoded before applying the format making the format string have no effect.
Response to comment:
You can try using the RowDataBound event.