Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
my jqgrid colModel is:
C#
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:

C#
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.
Posted
Comments
Sunasara Imdadhusen 7-May-14 6:44am    
Have you verified the email field which is coming from client is in correct format when you trying to save edited record?
Sachin Vashishth 12-May-14 7:46am    
Yes...
the error is coming when i try to edit the row.<br>
I am not editing the email field instead it shows email format is wrong,<br>
At the time of adding a new row the same id is accepted as a correct mail.<br>
Regards,
Sachin Vashishth

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900