본문 바로가기

Web/Asp.net

Asp.net mvc 개발토끼 강의 정리12

참고: [ASP.NET MVC] 12. 게시판 리스트 출력하기 - YouTube

 

#1 게시물 list출력하기

<controller>

public iactionResult index(){

 using(var db= new AspnetNoteDbContext())

{

 var list =db.Notes.ToList();

//Notes모델안에 있는 모든 데이터 가져와 list로 추가

}

return view(list); -->html은 list을 model로 인식

}

<index.html>

<th>번호</th>

<th>제목</th>

<th>작성자</th>

 

@foreach(var note int Model)

{

    <tr>

          <td>@note.NoteNo</td>

          <td>@note.NoteTitle</td>

          <td><@note.UserNo/td>

    <tr>

}

 <a asp-controller="Note" asp-action="add">게시물 작성<a> -->게시물 작성 버튼

 

'Web > Asp.net' 카테고리의 다른 글