添加记录时电子邮件格式正确但编辑同一记录JQgrid时格式错误不正确 [英] Email format is correct while adding the record but incorrect format error while editing the same record JQgrid
本文介绍了添加记录时电子邮件格式正确但编辑同一记录JQgrid时格式错误不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的jqgrid colModel是:
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();
}
大家好,
关于电子邮件格式的错误即将发生我正在编辑记录,如果格式正确,
如果我删除邮件ID并给另一个,然后记录编辑成功,
我也试过自定义功能,但错误仍然相同。
请有人为这个问题提供解决方案,我也是新的Jquery和Jqgrid。
推荐答案
(' #jQGridDemo')。jqGrid( ' navGrid',' #jQGridDemoPager' ,
{
edit: true ,
add : true ,
del: t rue ,
搜索: true ,
refresh: true ,
searchtext:' search',
addtext:' 添加',
edittext:' edit',
deltext:' delete'
('#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();
}
大家好,
关于电子邮件格式的错误即将发生我正在编辑记录,如果格式正确,
如果我删除邮件ID并给另一个,然后记录编辑成功,
我也试过自定义功能,但错误仍然相同。
请任何人为这个问题提供解决方案,我也是新的Jquery和Jqgrid。
这篇关于添加记录时电子邮件格式正确但编辑同一记录JQgrid时格式错误不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文