time(0) SQL データ フィールドにバインドする GridView コントロールがあります。DataFormatString プロパティを使用して、出力を AM/PM (例: 1:35 PM) としてレンダリングしたいと思います。いくつかの異なる値を割り当てようとしましたが、コンパイラは「入力文字列が正しい形式ではありませんでした」をスローします。ほとんどの場合エラー。これまでのところ、次の値を試しました:
{0:hh:mm tt}
{0:hh:mm:ss tt}
{0:hh:mm t}
{0:hh:mm:ss t}
{0:t} - 準拠しますが、フォーマットを変換しません
{0:tt} - 準拠しますが、フォーマットを変換しません
<asp:GridView SkinID="ResultsGrid" ID="GridViewAlerts" style="margin-top:2%"
runat="server" DataKeyNames="ID" AutoGenerateColumns="False" OnPageIndexChanging="GridViewAlerts_PageIndexChanging"
OnSorting="GridViewAlerts_Sorting" OnRowCommand="GridViewAlerts_RowCommand"
OnDataBound="GridViewAlerts_DataBound">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID"
ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="5%">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"
ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="10%">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description"
ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="30%">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="30%" />
</asp:BoundField>
<asp:BoundField DataField="Interval" HeaderText="Interval" SortExpression="Interval" ItemStyle-HorizontalAlign="Left"
HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="5%">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="Run_At" HeaderText="At" SortExpression="Run_At" ItemStyle-HorizontalAlign="Left"
HeaderStyle-HorizontalAlign="Left" DataFormatString="{0:t}" ItemStyle-Width="5%">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="Last_Run_Dt" HeaderText="Last Run" SortExpression="Last_Run_Dt" ItemStyle-HorizontalAlign="Left"
HeaderStyle-HorizontalAlign="Left" DataFormatString="{0: MM/dd/yyyy}" ItemStyle-Width="5%">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="Next_Run_Dt" HeaderText="Next Run" SortExpression="Next_Run_Dt" ItemStyle-HorizontalAlign="Left"
HeaderStyle-HorizontalAlign="Left" DataFormatString="{0: MM/dd/yyyy}" ItemStyle-Width="5%">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="Last_Result" HeaderText="Result" SortExpression="Last_Result" ItemStyle-HorizontalAlign="Left"
HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="5%" >
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="Active" HeaderText="Status" SortExpression="Active"
ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="5%">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="Owner" HeaderText="Owner" SortExpression="Owner"
ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="5%">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="5%" />
</asp:BoundField>
<asp:CommandField ButtonType="Image" SelectImageUrl="~/Images/gear.png" HeaderText="Settings" ShowSelectButton="true" ShowHeader="True" ItemStyle-Width="5%" />
<asp:TemplateField HeaderText="Start/Stop" ItemStyle-Width="5%">
<ItemTemplate>
<asp:ImageButton runat="server" ID="ImageButtonStartStop" ToolTip="Start or stop this alert" ImageUrl="~/Images/start.png"
OnClientClick="GridViewAlerts_RowCommand" CommandName="StartStop" CausesValidation="false"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Run" ItemStyle-Width="5%">
<ItemTemplate>
<asp:ImageButton runat="server" ID="ImageButtonRun" ToolTip="Manually run this alert" ImageUrl="~/Images/play.png"
OnClientClick="GridViewAlerts_RowCommand" CommandName="Run" CausesValidation="false"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
![screenshot][1]