ASP.NetのDetailsViewは、LateTimeArrivedAtSchoolと呼ばれるテンプレートフィールドです。このフィールドのデータは、SQLServerの[時間]列からのものです。データベース内のデータは、時間、分、秒として保存されます。
時間と分のみで表示したいと思います。
テンプレートフィールドのマークアップは次のとおりです。
<asp:TemplateField HeaderText="Late Time Arrived At School:" SortExpression="LateTimeArrivedAtSchool">
<EditItemTemplate>
<asp:TextBox ID="TextBoxLateTimeArrivedAtSchool" runat="server"
Text='<%# Bind("LateTimeArrivedAtSchool") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBoxLateTimeArrivedAtSchool" runat="server"
Text='<%# Bind("LateTimeArrivedAtSchool") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelLateTimeArrivedAtSchool" runat="server"
Text='<%# Bind("LateTimeArrivedAtSchool", "{0:hh:mm}") %>'></asp:Label>
</ItemTemplate>
<ItemStyle ForeColor="Blue" />
</asp:TemplateField>
「{0:hh:mm}」を使用すると、「入力文字列が正しい形式ではありませんでした」というエラーが生成されます。
Bindステートメントで何を使用する必要があるか教えてください。
*更新* 列のSQLServerデータ型をTime列からDateTime列に変更し、データの時間のみの部分を表示できるようにしました。