DataFormatString Doesn't Work

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>
 
L

Luc Kumps

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top