Hello,
I'm trying to pass a GridView as parameter from Javascript to a WebMethod. Here's my code:
- [WebMethod]
- public static string bindGrid1(GridView gv, String idno, String name, String tel)
- {
- string message = "";
- DataSet ds;
- SqlDataAdapter SqlAda;
- SqlConnection con = getConnection();
- SqlCommand cmd = new SqlCommand();
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.CommandText = "sproc";
- cmd.Parameters.Add("@IDNO", SqlDbType.VarChar).Value = idno;
- cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = name;
- cmd.Parameters.Add("@Tel", SqlDbType.VarChar).Value = tel;
- cmd.Connection = con;
- try
- {
- con.Open();
- gv.EmptyDataText = "No data.";
- SqlAda = new SqlDataAdapter(cmd);
- ds = new DataSet();
- SqlAda.Fill(ds);
- gv.DataSource = ds;
- gv.DataBind();
- message = "success";
- }
- catch (Exception ex)
- {
- appObj.myMessageBox(ex.Message);
- message = "error";
- }
- finally
- {
- con.Close();
- con.Dispose();
- }
- return message;
- }
Any kind of help would be appreciated.
Thank you in advance.
Nitin SontakkePosted Sep 15, 2016, 9:17 AM