Friday, October 19, 2012

Custome format of DateTime in WPF Data Grid


If we want to show only date and skip the time part
 
<DataGridTextColumn Header="Entry Date" Width="*" Binding="{Binding Path=DATE,StringFormat=\{0:dd.MM.yyyy \}}" >
</DataGridTextColumn >

Result is e.g. 19.10.2012

<DataGridTextColumn Header="Entry Date" Width="*" Binding="{Binding Path=DATE,StringFormat=\{0:dd.MM.yy \}}" >
</DataGridTextColumn >

Result is e.g. 19.10.12

<DataGridTextColumn Header="Entry Date" Width="*" Binding="{Binding Path=DATE,StringFormat=\{0:dd.MM.yy \}}" >
</DataGridTextColumn >

Result is e.g. 10.19.12



OR we can show only time without Date like
 

<DataGridTextColumn Header="Entry Date" Width="*" Binding="{Binding Path=DATE,StringFormat=\{0:HH.mm.ss \}}" >
</DataGridTextColumn >

Result will be like  22:19:33


Tuesday, October 9, 2012

Pass More Evals in QueryString with String.Formate



<asp:TemplateField HeaderText="EMail" SortExpression="EMail">
    <ItemTemplate> 
         <asp:HyperLink ID="hp" runat="server" 
                  CommandArgument='<%# Eval("SysID", "{0}") %>' 
       NavigateUrl='<%#  String.Format("~/ReportViewer.aspx?RevID= {0} 
      & User={1}", Eval("ID"),  Eval("USER")) %>' Target="_blank"  %>'>
</asp:HyperLink>
     </ItemTemplate>
</asp:TemplateField>