지난 며칠 동안 나는 MVC와 협력 해왔다. ...MVC3에서 Grid에 데이터를 바인딩하는 방법은 무엇입니까?
그리드에서 많은 데이터를 보여줘야한다. 나는이 모든 것을 테이블에 표시 할 수 있었지만 나의 요구 사항은 바인딩하는 것이다. 그것은 JQuery와 격자 또는 Webgrid ...
내가이 기대 아이디어와 제안을 수행하는 방법을 모르는이와 붙어입니다 ....
컨트롤러에
public ActionResult Index()
{
var bugList = GetList();
return View(bugList);
}
public List<ProjectModel> GetList()
{
var modelList = new List<ProjectModel>();
using (SqlConnection conn = new SqlConnection("Data Source=LMIT-0039;Initial Catalog=BugTracker;Integrated Security=True"))
{
conn.Open();
SqlCommand dCmd = new SqlCommand("Select * from Projects", conn);
SqlDataAdapter da = new SqlDataAdapter(dCmd);
DataSet ds = new DataSet();
da.Fill(ds);
conn.Close();
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
var model = new ProjectModel();
model.ID = Convert.ToInt16(ds.Tables[0].Rows[i]["ProjectID"]);
model.projectName = ds.Tables[0].Rows[i]["projectName"].ToString();
model.Description = ds.Tables[0].Rows[i]["Description"].ToString();
model.status = ds.Tables[0].Rows[i]["Status"].ToString();
modelList.Add(model);
}
}
return modelList;
}
보기 (ASPX)
<table>
<thead align="center">
<tr class="BoldCenterAlignHeaderStyle">
<th>
ProjectName
</th>
<th>
Status
</th>
<th align="center">
Edit
</th>
</tr>
</thead>
<% foreach (var item in Model) { %>
<tr>
<td>
<%:Html.LabelForModel(item.projectName) %>
</td>
<td>
<%:Html.LabelForModel(item.status) %>
</td>
<td align="center">
<a href="<%:Url.Action("Edit",new{id=item.ID}) %>" class="Edit"><img src="../../Content/edit.gif" height="8px"/></a>
<%--<%:Html.ActionLink("Edit", "Edit", new { id = item.ID })%> --%>
<%-- <a href="<%:Url.Action("Delete",new{id=item.ID}) %>" class="Delete"><img src="../../Content/delete.gif" height="8px" /></a>--%>
</td>
</tr>
<%} %>
내가 그렇게 할 수 그렇지 않으면 어떻게 하나가 제발 도움이 될 수 있습니다 자신에게 그리드에 데이터를 표시하는 방법을 테이블에 페이징을 할 수 있다면 ... . 어느 사람이 나를 어떻게 설명하는지.
% % <와 "@를 {"대체하고 <내 grind.GetHtml 포장 @anilkumar aspx 페이지 – SoftwareNerd