作者littlewon (QQ)
看板C_Sharp
标题[问题] GridView
时间Sun Jan 13 20:18:44 2008
我拉了一个GridView
其中删除grid的事件,我用程式写
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
SqlConnection pubs = new SqlConnection("Data Source=10.20.6.27;
Initial Catalog=DSCTEST; User ID=sa ;Password=sa15320");
DbConnection connection = new SqlConnection(pubs.ConnectionString);
DbCommand cmd = connection.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "DELETE FROM teamlist WHERE id='" +
GridView1.Rows[e.RowIndex].Cells[0].Text + "' ";
connection.Open();
DbDataReader rdr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(rdr);
connection.Close();
GridView1.DataSource = dt;
GridView1.DataBind();
}
建置後没错误
开网页按下删除时却没反应
想请问一下是程式哪里有问题呢??
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.65.162.2
1F:推 sheauren:单步看有没有进入上面的method 01/13 21:33
2F:推 tomex:Button的event常会因ide操作或移动而误移,再检查一下 01/16 02:31
3F:推 teyou:是不是要写在 RowCommand 里面? 建议你先读熟事件处理 01/18 01:46