私は、「dd-MM-yyyy」であるインド形式でSQL Server 2008に日付を保存する必要があるasp.net Webアプリケーションに取り組んでいます。テキストボックスに日付を入力してからSQLに保存するカレンダーエクステンダーがあります。
デザインは次のとおりです。
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="calStart" runat="server" TargetControlID="txtDate"
PopupButtonID="imgvStartDate" Format="dd/MM/yyyy"></asp:CalendarExtender>
<asp:ImageButton ID="imgvStartDate" runat="server" ImageUrl="~/images/iconCalendar.gif"
TabIndex="6" Style="margin-left: -0%; height: 18px;" />
コードビハインド:-
Entity_SupplierPayment objSupplierPayment = new Entity_SupplierPayment();
objSupplierPayment.Date = DateTime.ParseExact(txtDate.Text.Trim(), format, CultureInfo.CurrentCulture);
しかし、それはエラーを示しています:-- 文字列は有効な DateTime として認識されませんでした。