Comment lier les données de la Grille de MVC3?
Pour les derniers jours, j'ai travaillé avec MVC...
J'ai à vous montrer un tas de données dans une grille...tous ces jours, j'ai réussi à l'afficher dans une table, mais mon exigence est de le lier à jquery de grille ou de Webgrid...
Je suis coincé avec ce je ne sais pas comment faire cette s'attend à des idées et des suggestions....
Contrôleur
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;
}
Vue (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>
<%} %>
si je peux faire de la pagination dans un tableau comment puis-je faire sinon comment dois-je afficher les données dans une grille quelqu'un peut-il m'aider s'il vous plaît....quelqu'un peut-il m'expliquer comment faire ce
comment faire cela dans la page aspx
OriginalL'auteur SoftwareNerd | 2012-07-27
Vous devez vous connecter pour publier un commentaire.
Exemple pour webgrid:
remplacer "@{" avec <% et emballer vos cadeaux.GetHtml dans <%. N'oubliez pas de remplacer "@modèle" par "<%@Page" déclaration.
OriginalL'auteur Marian Ban
Vous pouvez utiliser Webgrid pour cela.
Voici quelques liens pour comprendre comment webgrid œuvres
Introduction à webgrid
http://www.mikesdotnetting.com/Article/154/Looking-At-The-WebMatrix-WebGrid
http://msdn.microsoft.com/en-us/magazine/hh288075.aspx
De pagination dans webgrid
http://yassershaikh.com/webgrid-paging-with-pager-method-in-razor-mvc/
Avancé (Efficace) de Pagination dans Webgrid
http://www.dotnetcurry.com/ShowArticle.aspx?ID=615
Espère que cela aide..!
OriginalL'auteur Yasser