There is a edit hyperlink in my table, when i click on my edit hyperlink a new edit window should be open and i want to edit the particular id row and when i made some changes and click on the save button the entire row should be saved in my sql database.
Here i am not using gridview and entity framework, i am using ado.net below is my code
now i want the code for edit action link
public ActionResult edit()
{
}
return View();
This code is for retrieving data:-
----------------------------------------
| username | password | address | emailid | |
|---|---|---|---|---|
| @item.username | @item.password | @item.address | @item.emailid | @Html.ActionLink("Edit", "getdata",new { id = item.userid }) | @Html.ActionLink("Delete", "getdata") |
public ActionResult getdata()
{
string conn = "Data Source=localhost;Integrated Security=true;Initial Catalog=employee";
SqlConnection cn = new SqlConnection();
cn.ConnectionString = conn;
SqlCommand cmd = new SqlCommand("select*from emp");
cmd.Connection = cn;
SqlDataAdapter adp = new SqlDataAdapter();
adp.SelectCommand = cmd;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
DataRow dr;
adp.Fill(ds);
dt = ds.Tables[0];
List c = new List();
for (int i = 0; i < dt.Rows.Count; i++)
{
dr = dt.Rows[i];
c.Add(new Class1()
{
// userid = Convert.ToDecimal(dr["userid"]),
username = Convert.ToString(dr["username"]),
password = Convert.ToString(dr["password"]),
address = Convert.ToString(dr["address"]),
emailid = Convert.ToString(dr["emailid"])
});
}
return View(c);
}
{
string conn = "Data Source=localhost;Integrated Security=true;Initial Catalog=employee";
SqlConnection cn = new SqlConnection();
cn.ConnectionString = conn;
SqlCommand cmd = new SqlCommand("select*from emp");
cmd.Connection = cn;
SqlDataAdapter adp = new SqlDataAdapter();
adp.SelectCommand = cmd;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
DataRow dr;
adp.Fill(ds);
dt = ds.Tables[0];
List
for (int i = 0; i < dt.Rows.Count; i++)
{
dr = dt.Rows[i];
c.Add(new Class1()
{
// userid = Convert.ToDecimal(dr["userid"]),
username = Convert.ToString(dr["username"]),
password = Convert.ToString(dr["password"]),
address = Convert.ToString(dr["address"]),
emailid = Convert.ToString(dr["emailid"])
});
}
return View(c);
}
This code is for sign up page:-
--------------------------------------