my jqgrid colModel is:
jQuery("#jQGridDemo").jqGrid({
url: 'http://localhost:63453/JQGridHandler.ashx',
datatype: "json",
colNames: ['Id', 'First Name','Address','Email'],
colModel: [
{ name: 'id', index: 'id', width: 20, stype: 'text', editable: true, editrules: { size: 20 } },
{ name: 'name', index: 'name', width: 150, editable: true },
{ name: 'address', index: 'address', width: 150, editable: true },
{ name: 'email', index: 'email', width: 150, editable: true, editrules: {required:true, email:true} },
],
rowNum: 50,
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: "List Employee Details",
autowidth: true,
pager: '#jQGridDemoPager',
editurl: 'http://localhost:63453/JQGridHandler.ashx'
});
$('#jQGridDemo').jqGrid('navGrid', '#jQGridDemoPager',
{
edit: true,
add: true,
del: true,
search: true,
refresh: true,
searchtext: 'search',
addtext: 'Add',
edittext: 'edit',
deltext: 'delete'
And the handler code for add/edit is as below:
if (strOperation == "add")
{
SqlConnection con = new SqlConnection("server=Ignitor-PC5;database=JQGridTest;uid=sa;pwd=Ignitor1234");
int intId = Convert.ToInt32(forms.Get("id"));
string strFirstName = forms.Get("name").ToString();
string straddress = forms.Get("address").ToString();
string stremail = forms.Get("email").ToString();
con.Open();
string QryString = "insert into grid values(" + intId + " ,' " + strFirstName + " ',' " + straddress + "' ,' " + stremail + " ')";
SqlCommand cmd = new SqlCommand(QryString, con);
cmd.ExecuteNonQuery();
strResponse = " Record added successfully";
context.Response.Write(strResponse);
con.Close();
}
else if (strOperation == "edit")
{
SqlConnection con = new SqlConnection("server=Ignitor-PC5;database=JQGridTest;uid=sa;pwd=Ignitor1234");
int intId = Convert.ToInt32(forms.Get("id"));
string strFirstName = forms.Get("name").ToString();
string straddress = forms.Get("address").ToString();
string stremail = forms.Get("email").ToString();
con.Open();
SqlCommand cmd = new SqlCommand("update grid set name=' " +
strFirstName + "',address='" + straddress + "' ,email='" + stremail + " ' where id= " + intId + " ", con);
cmd.ExecuteNonQuery();
strResponse = "Record edited successfully";
context.Response.Write(strResponse);
con.Close();
}
Hello everyone,
The error about email format is coming when i am editing the record if it is in correct format to,
If i remove the mail id and give another one then record edited successfully,
I have tried custom function too, but the error is still same.
please anyone give solution for this issue, I am new too Jquery and Jqgrid.