DataFormatString Doesn't Work

  • Thread starter Thread starter frank
  • Start date Start date
F

frank

I am using the DataFormatString property on BoundColumn objects in a
DataGrid, but they don't seem to work for some reason.

I copied them straight from another DataGrid where they work fine, but for
some reason they have no effect in the following grid.

The two that don't work are DataFormatString="{0:dd-MM-yyyy}" and
DataFormatString="{0:C}".

The code is below. Anyone got any ideas what the problem is?

<asp:DataGrid id="ClientPoliciesGrid" runat="server"
AutoGenerateColumns="False"
AllowPaging="false"
PagerStyle-Mode="NumericPages"
PagerStyle-BackColor="#006666"
PagerStyle-ForeColor="#FFFFFF"
PageSize="15"
BackColor="#d0e0d0"
HorizontalAlign="Left"
Font-Bold="False" Font-Name="Tahoma"
Font-Size="10pt"<Columns>
<asp:TemplateColumn HeaderText="QID" >
<ItemTemplate>
<asp:HyperLink
runat="server"
id="lnkViewSchedule"
Text='<%#"<b>" + DataBinder.Eval(Container.DataItem, "QID") +
"</b>"%>'
NavigateUrl='<%#"~/crm/viewSchedule.aspx?qid=" +
DataBinder.Eval(Container.DataItem, "QID") + "&sid=" +
DataBinder.Eval(Container.DataItem, "SchemeID") %>'
/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Policy_Number" HeaderText="Policy Number">
<ItemStyle HorizontalAlign="Center" Width="180" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Risk_Postcode" HeaderText="Postcode">
<ItemStyle HorizontalAlign="Center" Width="60" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Inception_Date" HeaderText="Inception"
DataFormatString="{0:dd-MM-yyyy}">
<ItemStyle HorizontalAlign="Center" Width="80" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Expiry_Date" HeaderText="Expiry"
DataFormatString="{0:dd-MM-yyyy}">
<ItemStyle HorizontalAlign="Center" Width="80" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Single_Premium" HeaderText="Premium"
DataFormatString="{0:C}">
<ItemStyle HorizontalAlign="Center" Width="80" />
</asp:BoundColumn>
<asp:BoundColumn DataField="On_Cover" HeaderText="On Cover">
<ItemStyle HorizontalAlign="Center" Width="60" />
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Claim" >
<ItemTemplate>
<center>
<asp:HyperLink
runat="server"
id="lnkNewClaim"
Text='<%#"<b>New</b>"%>'
NavigateUrl='<%#"~/claims/newClaim.aspx?gcid=" +
DataBinder.Eval(Container.DataItem, "gCID") + "&qid=" +
DataBinder.Eval(Container.DataItem, "QID") + "&sid=" +
DataBinder.Eval(Container.DataItem, "SchemeID") %>'
/>
</center>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>

<HeaderStyle BackColor="#006666" ForeColor="White"
Font-Bold="True" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" />
</asp:DataGrid>
 
frank said:
I am using the DataFormatString property on BoundColumn objects in a
DataGrid, but they don't seem to work for some reason.

Could you describe "does not work" just a *little* bit more?

Luc K
 
Back
Top