作者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