I m performing crud operation using ajax jquery. I m inserting data in the database but I want to get the data and that data update and delete run time but my getdata method does not work??
Emploee.aspx.cs
- [WebMethod] //insert
- public static void insertdata(string name, int age, string address)
- {
- cn.Open();
- SqlCommand cmd = new SqlCommand("sp_tblEmployee_Insert", cn);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@EmpName", name);
- cmd.Parameters.AddWithValue("@EmpAge", age);
- cmd.Parameters.AddWithValue("@EmpAddress", address);
- cmd.ExecuteNonQuery();
- cn.Close();
- }
- [WebMethod]
- public static string GetEmpData()
- {
- cn.Open();
- string data = "";
- SqlCommand cmd = new SqlCommand("sp_tblEmployee_Select", cn);
- cmd.CommandType = CommandType.StoredProcedure;
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- DataSet ds = new DataSet();
- da.Fill(ds);
- cn.Close();
- if (ds.Tables[0].Rows.Count > 0)
- {
- data = JsonConvert.SerializeObject(ds.Tables[0]);//read and write the jsontext
- }
- return data;
- }
Emploee.aspx
- "server">
- "StyleSheet.css" rel="stylesheet" />
Jquery Crud Index Update Delete - runat="server">
Name: - "text" id="txtName" />
Age: - "text" id="txtAge" />
Address: - "text" id="txtAddress" />
- "button" id="btnsubmit" value="Submit" onclick="SaveData()" />
"tbl">
Enmployee Name Employee Age Employee Address