Click here to Skip to main content
11,630,646 members (78,472 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: LINQ MySQL MVC
This can run well with MSSQL,but after i change the database with mysql,it just show the firt
page, the viewdata.model can't get the next page record.

code in controllor:

index action:
if (Request["page"] != null)
           {
 
               ViewData["page"] = SqlHelper.Pager(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf("?")), Convert.ToInt32(Request["page"]), n.Count(), 5, 3);
               n = n.Skip((Convert.ToInt32(Request["page"]) - 1) * 5).Take(5);
 
           }
           else
           {
               ViewData["page"] = SqlHelper.Pager(Request.RawUrl, 1, n.Count(), 5, 3);
 
               n = n.Skip(0).Take(5);
           }
 

 
           return View(n);


code in SqlHelper:

public static string Pager(string url1, int id, int count, int size, int show)
       {
           string pager = "";
           string url = url1.Contains("?") ? url1 + "&page=" : url1 + "?page=";
           pager = "<a href=\"" + url + (1) + "\"><<</a>";
           if (id != 1)
           {
               pager += "<a href=\"" + url + (id - 1) + "\"><</a>";
           }
           if (id >

index.aspx code:

<% foreach (MvcBBS.Model.Article m in (IEnumerable)ViewData.Model)
       { %>
      <dt class="d"><%= Html.ActionLink(Html.Encode(m.Title), "Read", "Article", new { ID = m.ID}, null)%>&nbsp;&nbsp;&nbsp;&nbsp;
       <% if (Session["Flag"] == "1")
          { %>
         &nbsp;&nbsp;&nbsp;&nbsp; <span style="float:right">
          <%= Ajax.ActionLink("[Delete]", "Delete", new { ID = m.ID, SortID = m.Sort }, new AjaxOptions { UpdateTargetId = "divArticleList", Confirm="are you sure?" })%></span>
       <%} %>
 
       &nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#0099CC"><%= m.ReplyNum %></span>&nbsp;/&nbsp;<%= m.ReadNum %>
      &nbsp;&nbsp;&nbsp;&nbsp;<%= m.author%>
      &nbsp;&nbsp;&nbsp;&nbsp;<%= m.EntryDate %></dt>
 
    <%} %>
 <div class="page">&nbsp;&nbsp;<%=ViewData["page"] %>  </div>

related css:

.pagecomments{
    width: 500px;
    margin: 27px;
    padding: 27px;
}
 
.pagecomments h3{
    color: #6a6a6a;
}
 
.pagecomments a{
    color: #b7a795;
    text-decoration: none;
    font-size: 11px;
    background-color: #fdf8f1;
}
 
.pagecomments a:hover{
    color: #a9b880;
}
 
.pagecomments ol{
    list-style: none;
    margin: 10px 0;
    padding: 0;
}
 
.pagecomments ol li{
    list-style: none;
    margin: 10px 0 0;
    padding: 0 0 10px;
    border-bottom: 1px dotted #bbb7b0;
    line-height: 22px;
}
 
#pagecomments span.comment-author{
    font-weight: bold;
    text-decoration: underline;
}
 
#respond{
    padding: 10px;
    border: 1px dotted #bbb7b0;
 
}

someone would help me? thx a lot!!!
Posted 6-Mar-13 4:40am
gavinv421

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


Advertise | Privacy | Mobile
Web03 | 2.8.150723.1 | Last Updated 12 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100