title: ASP.net Mvc 2.0 with JQGrid
body: <p>I have to implement inline editing with combobox in JQGrid,and i have to populate data in combobox from database no hard coded value i have already written the view part and i am using Linq to Sql as model but not able to write controller for that. I have got one sample for that but in sample repository design pattern has been used and i have not to use that.So can any on help me to write thebcontroller part.
  My view part is </p>
  
  <pre><code>&lt;%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage&lt;dynamic&gt;" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head runat="server"&gt;
      &lt;link href="../../Content/jquery-ui-1.10.4.custom.min.css" rel="stylesheet" type="text/css" /&gt;
      &lt;link href="../../Content/ui.jqgrid.css" rel="stylesheet" type="text/css" /&gt;
      &lt;script src="../../Scripts/JQGrid/jquery-1.11.0.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="../../Scripts/JQGrid/jquery.jqGrid.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="../../Scripts/JQGrid/jquery.jqGrid.src.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="../../Scripts/JQGrid/grid.locale-en.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          $(document).ready(function () {
              $("#Grid").jqGrid(
        { url: '/Default/GetData',
            datatype: 'json',
            mtype: 'GET',
            colNames: ['Id', 'UserName', 'Organization', 'Report Type', 'EmailID', 'Action'],
            colModel: [
  
              { name: 'Id', index: 'Id', align: 'center', width: 30, editable: false },
  
             { name: 'UserName', index: 'UserName', align: 'center', width: 150, editable: true, edittype: 'select', formatter: 'select', editoptions: { dataUrl: '/Default/UserSelect' } },
  
             { name: 'Organization', index: 'Organization', align: 'center', width: 200, editable: true, edittype: 'select', formatter: 'select', editoptions: { dataUrl: '/Default/OrganizationSelect' }, editrules: { required: true} },
  
             { name: 'Report Type', index: 'Report Type', align: 'center', width: 200, editable: true, edittype: 'select', editoptions: { value: 'MN:Monthly; YR:Yearly', defaultValue: 'Montyhly'} },
  
             { name: 'EmailID', index: 'EmailID', align: 'center', width: 250, editable: true, edittype: 'text', editoptions: { size: 30, maxlength: 40} },
  
             { name: 'act', width: 100, align: 'center', sortable: false, formatter: 'actions', formatoptions: { keys: true, editbutton: true}}],
  
  
            pager: jQuery('#pager'),
            rowNum: 10,
            rowList: [5, 10, 20, 50],
            sortname: 'Id',
            sortorder: "asc",
            viewrecords: true,
            caption: 'Regen Users'
  
        });
          });
  
  
      &lt;/script&gt;
  
      &lt;title&gt;Index&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div&gt;
      &lt;table id="Grid"&gt;
      &lt;/table&gt;
      &lt;/div&gt;
      &lt;div id="pager"&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And my get data controller is as</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using Important.Models;
  using System.Linq.Dynamic;
  
  namespace Important.Controllers
  {
      public class DefaultController : Controller
      {
          RegenDataContext db = null;
          public DefaultController()
          {
              db = new RegenDataContext();
          }
  
          public ActionResult Index()
          {
              return View();
          }
          [HttpGet]
          public ActionResult GetData(string sidx, string sord, int page, int rows)
          {
              var pageIndex = Convert.ToInt32(page) - 1;
              var pageSize = rows;
              var totalRecords = db.rptUsers.Count(); 
              var totalPages = (int)Math.Ceiling(totalRecords / (float)pageSize);
  
  
              var user = db.rptUsers
                  .OrderBy(sidx + " " + sord)
                  .Skip(pageIndex * pageSize)
                  .Take(pageSize).AsQueryable();
  
              var jsonData = new
              {
  
                  rows = (
                  from rptUser u in user
                  select new 
                  {
                      i=u.ID,
                      cell=new string[]{u.ID.ToString(),u.UserName, u.UserOrganizationID.ToString()}
                  }).ToArray()
  
                  };
              return Json(jsonData, JsonRequestBehavior.AllowGet);
          }
  
  
          public ActionResult UserSelect()
          {
  
  
              return View();
          }
  
          public ActionResult OrganizationSelect()
          {
              return View();
          }
      }
  </code></pre>
  
  <p>}</p>
  
  <p>help me to write controller action for data url UserSelect.</p>