Monday 19 November 2012

Pagging logic in MVC

StringBuilder sb = new StringBuilder();

                sb.Append("<span class=\"pagshow\">Show</span><select id=\"ddlPageSize\" onchange=\"loadData(0)\" >");
                if (intPageSize == 10)
                {
                    sb.Append("<option value=\"10\"  selected=\"selected\" >10</option>");
                }
                else
                {
                    sb.Append("<option value=\"10\">10</option>");
                }
                if (intPageSize == 25)
                {
                    sb.Append("<option value=\"25\" selected=\"selected\" >25</option>");
                }
                else
                {
                    sb.Append("<option value=\"25\" >25</option>");
                }
                if (intPageSize == 50)
                {
                    sb.Append("<option value=\"50\" selected=\"selected\">50</option>");
                }
                else
                {
                    sb.Append("<option value=\"50\">50</option>");
                }
                if (intPageSize == 75)
                {
                    sb.Append("<option value=\"75\" selected=\"selected\" >75</option>");
                }
                else
                {
                    sb.Append("<option value=\"75\">75</option>");
                }
                if (intPageSize == 100)
                {
                    sb.Append("<option value=\"100\" selected=\"selected\"  >100</option>");
                }
                else
                {
                    sb.Append("<option value=\"100\">100</option>");
                }
                sb.Append("</select>Entries</span>");
                sb.Append("<ul class=\"pagination fr\"  >");
                sb.Append("<li class=\"first\">");
                if (intCurrentIndex == 0)
                {
                    sb.Append("<a href=\"javascript:void(0)\" class=\"disable\"  >‹‹</a>");
                }
                else
                {
                    sb.Append("<a href=\"javascript:void(0)\" onclick=\"loadData(0)\" >‹‹</a>");
                }
                sb.Append("</li>");

                sb.Append("<li class=\"previous\">");
                if (intCurrentIndex == 0)
                {
                    sb.Append("<a href=\"javascript:void(0)\" class=\"disable\">‹</a>");
                }
                else
                {
                    sb.Append("<a href=\"javascript:void(0)\" onclick=\"loadData(" + (intCurrentIndex - 1) + ")\" >‹</a>");
                }
                sb.Append("</li>");
                sb.Append("<li class=\"next\">");
                if ((intCurrentIndex == intTotalRowCount - 1) || intTotalRowCount == 0)
                {
                    sb.Append("<a href=\"javascript:void(0)\" class=\"disable\">›</a>");
                }
                else
                {
                    sb.Append("<a href=\"javascript:void(0)\" onclick=\"loadData(" + (intCurrentIndex + 1) + ")\" >›</a>");
                }
                sb.Append("</li>");

                sb.Append("<li class=\"last\">");
                if ((intCurrentIndex == intTotalRowCount - 1) || intTotalRowCount == 0)
                {
                    sb.Append("<a href=\"javascript:void(0)\" class=\"disable\">››</a>");
                }
                else
                {
                    sb.Append("<a href=\"javascript:void(0)\"  onclick=\"loadData(" + (intTotalRowCount - 1) + ")\" >››</a>");
                }
                sb.Append("</li>");
                sb.Append("</ul>");
                return sb.ToString();



No comments:

Post a Comment