hi...
im givin you one example..hope this may help you..
in the view yuo shud write like this
$(document).ready(function () {
var updateDialog = {
url: '/Home/Update/'
, closeAfterAdd: true
, closeAfterEdit: true
, afterclickPgButtons: function (whichbutton, formid, rowid) {
}
, modal: true
, onclickSubmit: function (params) {
var ajaxData = {};
var list = $("#list");
var selectedRow = list.getGridParam("selrow");
rowData = list.getRowData(selectedRow);
ajaxData = { intFerryId: rowData.intFerryId };
return ajaxData;
}
, width: "400"
};
$.jgrid.nav.addtext = "Add";
$.jgrid.nav.edittext = "Edit";
$.jgrid.nav.deltext = "Delete";
$.jgrid.edit.addCaption = "Add Ferry";
$.jgrid.edit.editCaption = "Edit Ferry";
$.jgrid.del.caption = "Delete Ferry";
$.jgrid.del.msg = "Delete selected Ferry?";
jQuery("#list").jqGrid({
url: '/Home/JsonSalesCollection/',
datatype: "json",
mtype: 'GET',
colNames: ['FerryId', 'FerryName', 'FerryDuration'],
colModel: [
{ name: 'intFerryId', index: 'intFerryId', width: 50, align: 'left' },
{ name: 'strFerryName', index: 'strFerryName', width: 100, align: 'left', editable: true, edittype: 'text', editrules: { required: true }, formoptions: { elmsuffix: ' *'} },
{ name: 'tmFerryDuration', index: 'tmFerryDuration', width: 100, align: 'left', editable: true, edittype: 'text', editrules: { required: true }, formoptions: { elmsuffix: ' *'}}],
rowNum: 10,
rowList: [10, 20, 30],
imgpath: gridimgpath,
height: 'auto',
width: '300',
pager: jQuery('#pager'),
sortname: 'intFerryId',
viewrecords: true,
sortorder: "desc",
caption: "Ferry Details", autowidth: true,
ondblClickRow: function (rowid, iRow, iCol, e) {
$("#list").editGridRow(rowid, prmGridDialog);
}
}).navGrid('#pager',
{
edit: true, add: true, del: true, search: false, refresh: true
}, updateDialog,
updateDialog,
updateDialog
);
});
in the controller code is like this
you shud create an object of FormCollection in your controller.If u hav any doubt just ask to me...
the controller code is given below
public ActionResult Update( FormCollection formCollection)
{
ferry obj=new ferry();
var operation = formCollection["oper"];
if (operation.Equals("add") )
{
obj.FerryDuration = formCollection.Get("tmFerryDuration").ToString();
obj.FerryName = formCollection.Get("strFerryName").ToString();
obj.SaveOrUpdate();
}
else if(operation.Equals("edit"))
{
obj.FerryDuration = formCollection.Get("tmFerryDuration").ToString();
obj.FerryId = int.Parse(formCollection.Get("intFerryId").ToString());
obj.FerryName = formCollection.Get("strFerryName").ToString();
obj.SaveOrUpdate();
}
else if (operation.Equals("del"))
{
obj.FerryId = int.Parse(formCollection.Get("intFerryId").ToString());
obj.Delete();
}
return Content(obj.HasErrors.ToString().ToLower());
}
Updated 7-Dec-10 23:04pm
v2