I am Ranjitha ,i am able to display data in gridview ,can anyone let me know how to do pagination in mvc . iam posting my code if any changes are can u let me know.
default1 controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PERFJQGIRD.Controllers;
using PERFJQGIRD.Models;
using MySql.Data.MySqlClient;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PERFJQGIRD.Controllers;
using PERFJQGIRD.Models;
using MySql.Data.MySqlClient;
using System.Data;
using System.Data.SqlClient;
namespace PERFJQGIRD.Controllers
{
public class Default1Controller : Controller
{
//
// GET: /Default1/
{
public class Default1Controller : Controller
{
//
// GET: /Default1/
public ActionResult Index()
{
return View();
}
[HttpGet]
public JsonResult GetData(string ReleaseId, string ReleaseName, string Scopelockdate, string ReleaseDate, string Segment, string Query, string Status)
{
{
return View();
}
[HttpGet]
public JsonResult GetData(string ReleaseId, string ReleaseName, string Scopelockdate, string ReleaseDate, string Segment, string Query, string Status)
{
List ObjClass = new List();
// MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=prefautomationdb;password=Password@2");
// con.Open();
// MySqlCommand cmd = new MySqlCommand();
// cmd.CommandText = "getReleaseDetails";
//cmd.CommandType = CommandType.StoredProcedure;
MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=prefautomationdb;password=Password@2");
con.Open();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM tfsperfqueue", con);
//MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
//DataSet ds = new DataSet();
//adp.Fill(ds);
//cmd.Dispose();
//con.Close();
// MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=prefautomationdb;password=Password@2");
// con.Open();
// MySqlCommand cmd = new MySqlCommand();
// cmd.CommandText = "getReleaseDetails";
//cmd.CommandType = CommandType.StoredProcedure;
MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=prefautomationdb;password=Password@2");
con.Open();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM tfsperfqueue", con);
//MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
//DataSet ds = new DataSet();
//adp.Fill(ds);
//cmd.Dispose();
//con.Close();
//return Json(ObjClass, JsonRequestBehavior.AllowGet);
var model = new List();
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
var release1 = new Class1();
release1.ReleaseId = Convert.ToInt32(rdr["Release_Id"]);
release1.ReleaseName = Convert.ToString(rdr["Release_Name"]);
release1.Scopelockdate = Convert.ToDateTime(rdr["Scope_lock_date"]);
release1.Releasedate = Convert.ToDateTime(rdr["Release_Date"]);
release1.Segment = Convert.ToString(rdr["Segment"]);
release1.Query = Convert.ToString(rdr["Query"]);
release1.Status = Convert.ToInt32(rdr["Status"]);
model.Add(release1);
}
var model = new List
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
var release1 = new Class1();
release1.ReleaseId = Convert.ToInt32(rdr["Release_Id"]);
release1.ReleaseName = Convert.ToString(rdr["Release_Name"]);
release1.Scopelockdate = Convert.ToDateTime(rdr["Scope_lock_date"]);
release1.Releasedate = Convert.ToDateTime(rdr["Release_Date"]);
release1.Segment = Convert.ToString(rdr["Segment"]);
release1.Query = Convert.ToString(rdr["Query"]);
release1.Status = Convert.ToInt32(rdr["Status"]);
model.Add(release1);
}
return Json(model, JsonRequestBehavior.AllowGet);
}
}
}
}
}
Index
@{
ViewBag.Title = "Index";
}
ViewBag.Title = "Index";
}
Index
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Puneet KankarPosted Jul 20, 2017, 4:11 AM
Manikandan MurugesanPosted Jul 20, 2017, 3:33 AM