我已经在 asp.net mvc3 中使用网格绑定了数据。我在绑定表中的编辑链接中遇到问题。如果我单击编辑链接,它没有响应。这是我所拥有的:
教师.cs
public class Teacher
{
public static List<Teacher> GetList { get; set; }
public int T_Id { get; set; }
public string T_Name { get; set; }
public string T_Address { get; set; }
public string Sub_Id { get; set; }
}
教师控制器
public ActionResult Edit(int id,string T_Name,string T_Address,string Sub_Id)
{
// Teacher list= new Teacher();
var edit = EditList();
//list.T_Id = Convert.ToInt32(T_Id);
return View(edit);
}
[HttpPost]
public ActionResult EditList()
{
var editlist = new List<Teacher>();
using (SqlConnection conn = new SqlConnection(@"Integrated ecurity=SSPI;Persist Security Info=False;Initial Catalog=Demo;Data Source=CIPL41\SQLEXPRESS"))
{
conn.Open();
var modeledit = new Teacher();
SqlCommand cmd = new SqlCommand("edit", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@T_Id", modeledit.T_Id);
cmd.Parameters.AddWithValue("@T_Name", modeledit.T_Name);
cmd.Parameters.AddWithValue("@T_Address", modeledit.T_Address);
cmd.Parameters.AddWithValue("@Sub_Id", modeledit.Sub_Id);
cmd.ExecuteNonQuery();
conn.Close();enter code here
editlist.Add(modeledit);
}
return View(editlist);
}