Durga Velusamy

Durga Velusamy

  • NA
  • 318
  • 115.2k

how to pass values using array from list

Jul 11 2015 12:15 AM
my front is
<input type="button" value="Save" onclick=" fn_save()"/>
 
the below code does not work pls tell me what mistake i have done here 
 
function fn_save()
{
try
{
endEditing();
var rows = $('#dg_main').datagrid('getRows');
Appjquery.WebService1.insert(is_connstring, rows, update_result, GetFault_result1);
}
catch (e)
{
alert(e);
}
}
function update_result(result)
{
if (result[0].dsexecstatus = "FAIL")
{
document.getElementById("lbl_msg").innerHTML = result[0].dsmsg;
}
else
{
document.getElementById("lbl_msg").innerHTML = result[0].dsmsg;
}
}
function GetFault_result1(result)
{
document.getElementById("lbl_msg").innerHTML = result[0].dsmsg;
}
my backend is 
 
[WebMethod(EnableSession = true)]
public List<Emptab> insert(string[] as_connstring, List<Emptab> as_values)
{
Emptab tdat = new Emptab();
List<Emptab> tdata_list = as_values;
try
{
string[] arr = new string[3];
foreach (Emptab tdata in tdata_list)
{
arr[0] = tdata.rnumber;
arr[1] = tdata.sname;
arr[2] = tdata.depart;
arr[3] = tdata.active;
}
string ls_query = "";
if (as_connstring[0] == "GET")
{
ls_query = @"insert into student values('" + arr[0] + "','" + arr[1] + "','" + arr[2] + "','" + arr[3] + "') ";
odcon = new OdbcConnection(con);
odcon.Open();
comm = new OdbcCommand(ls_query, odcon);
comm.ExecuteNonQuery();
tdat.dsexecstatus = "SUCCESS";
tdat.dsmsg = "Datas From Table";
tdata_list.Add(tdat);
}
else
{
tdat.dsexecstatus = "Fail";
tdat.dsmsg = "Fail to Update";
tdata_list.Add(tdat);
}
}
catch (Exception)
{
throw;
}
odcon.Close();
return tdata_list;
}
}
}
 

Answers (5)