C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

No.90037 の関連記事表示

<< 0 >>
■90037  Re[2]: TextBoxForでHttppost時の通貨書式→数値変換
□投稿者/ ジョディー -(2019/01/31(Thu) 22:54:42)
    2019/01/31(Thu) 23:10:50 編集(投稿者)
    2019/01/31(Thu) 23:09:08 編集(投稿者)
    2019/01/31(Thu) 23:07:43 編集(投稿者)
    <pre><pre>2019/01/31(Thu) 23:07:17 編集(投稿者)

    <pre><pre>ジョディーです。図表モードでソースコードを記載してみました。
    これでよろしいでしょうか?
    ソースコードは長いので、パラメータを一部に絞ったソースコードの抜粋を以下に示します。
    抜粋する難しさを痛感しております。

    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;

    namespace Contract.Models
    {
    public class Keiyaku
    {
    public int ID { get; set; }

        [Display(Name = "契約日")]
        public DateTime ContractDate { get; set; }
        [Column("money")]
        [Display(Name = "価格")]
        public decimal Price { get; set; }
    }
    }

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Entity;
    using System.Linq;
    using System.Net;
    using System.Web;
    using System.Web.Mvc;
    using Contract.DAL;
    using Contract.Models;

    namespace Contract.Controllers
    {
    public class ContractController : Controller
    {
    private KeiyakuContext db = new KeiyakuContext();

    public ActionResult Edit(int? id)
    {
    if (id == null)
    {
    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
    }
    Keiyaku keiyaku = db.Keiyaku.Find(id);
    if (keiyaku == null)
    {
    return HttpNotFound();
    }
    return View(keiyaku);
    }

    // POST: Contract/Edit/5
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Edit([Bind(Include = "ID,ContractDate,Price")] Keiyaku keiyaku)
    {
    if (ModelState.IsValid)
    {
    db.Entry(keiyaku).State = EntityState.Modified;
    db.SaveChanges();
    return RedirectToAction("Index");
    }
    return View(keiyaku);
    }
    protected override void Dispose(bool disposing)
    {
    if (disposing)
    {
    db.Dispose();
    }
    base.Dispose(disposing);
    }
    }
    }

    @model Contract.Models.Keiyaku

    ・・・
    <h2>編集</h2>

    @using (Html.BeginForm())
    {
    <div>
    <dl class="dl-horizontal">
    <dt>詳細情報</dt>
    <dd>

    <th>契約日</th>
    <td>@Html.TextBoxFor(model => model.Keiyaku.ContractDate, "{0:yyyy/MM/dd}")</td>
    @Html.ValidationMessageFor(model => model.Keiyaku.ContractDate)

    <th>価格</th>
    <td>@Html.TextBoxFor(model => model.Keiyaku.Price,"{0:c}")</td>
    @Html.ValidationMessageFor(model => model.Keiyaku.Price)
    </dd>
    <div>
    <input type="submit" name="save" value="保存" formmethod="post" />
    </div>
    <p>
    @Html.ActionLink("一覧に戻る", "Index")
    </p>
    @section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    }


    以上です。よろしくお願い致します。
    </pre></pre></pre></pre>
記事No.90016 のレス /過去ログ155より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -