LoginSignup
0
1

More than 5 years have passed since last update.

ASP.net MVC + VB.net Oracle 検索画面

Last updated at Posted at 2016-07-27

概要

検索画面では、検索キーを入力して検索結果を表示する。
この当たり前の処理をメモ。

環境

Visual Studio Community 2015
VB.net
.net framework4.5.2
Oracle11g
Oracle Client12c
IE11

前提

ADO.net Entity Framework⇒データベースからEF Designerで、edmxファイルを作成しておく。

実装

HogeController.vb
Dim db as New TESTEntities

Function Search(ByVal keyword As String)
 return View(db.TEST01.Where(Function(b) b.column01 = keyword))
Search.vbhtml
@modeltype IEnumerable(Of TEST01)
@Code
    ViewData("Title") = "Search"
End Code
<h2>Search</h2>
<!--検索部-->
@Using Html.BeginForm("Search", "HOGE", FormMethod.Post, New With {.class = "form-inline"})
    @Html.Label("keyword", "Column01:", New With {.class = "control-label"})
    @Html.TextBox("keyword", "", New With {.class = "form-control"})
    @<text>
    <input type="submit" value="検索" class="btn btn-link" />
    </text>
End Using
<!--表示部-->
<table class="table">
 <tr>
    <th>Column01</th>
    <th>Column02</th>
    <th>Column03</th>  
  </tr>
@For Each item In Model
  @<tr>
    <td>@item.column01</td>
    <td>@item.column02</td>
    <td>@item.column02</td>
  </tr>
Next
</table>

メモ

@Html.TextBox("keyword", ←この要素名が、
コントローラーの
Function Search(ByVal keyword As String) ←同じ名称でないと表示されない
なんでやろ=次までに調査=

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1