@foreach (DataRow row in dtViewUsers.Rows)
{
<tr >
<td>
<input type="hidden" value=@row["id"] id="hdnDelUser" />
<label for="@row["id"]">@row["id"]</label>
</td>
<td>
@row["name"].ToString()
</td>
<td>
@row["email"].ToString()
</td>
<td>
@row["country"].ToString()
</td>
<td>
@row["mobilenumber"].ToString()
</td>
<td>
@row["password"].ToString()
</td>
<td>
@row["expierence"].ToString()
</td>
<td>
@row["functionalarea"].ToString()
</td>
<td>
@row["isactive"].ToString()
</td>
<td>
<input type="button" id="btndel" name="delete" value="Delete" onclick="DeleteUser(this);" />
and in my home controller and Dal like this
public ActionResult DeleteUser(string UID)
{
int UserID = v.DelUser(UID);
return Json(UserID, JsonRequestBehavior.AllowGet);
}
internal int DelUser(string UID)
{
int i=0;
SqlConnection con=new SqlConnection(s);
SqlCommand cmd = new SqlCommand("Sp_DelUser", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.NVarChar)).Value = UID;
con.Open();
object obj = cmd.ExecuteScalar();
if (obj != null)
{
i = (int)obj;
}
return i;
}
TIA