[問題] GridView

看板C_Sharp作者 (QQ)時間16年前 (2008/01/13 20:18), 編輯推噓3(300)
留言3則, 3人參與, 最新討論串1/2 (看更多)
我拉了一個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

01/13 21:33, , 1F
單步看有沒有進入上面的method
01/13 21:33, 1F

01/16 02:31, , 2F
Button的event常會因ide操作或移動而誤移,再檢查一下
01/16 02:31, 2F

01/18 01:46, , 3F
是不是要寫在 RowCommand 裡面? 建議你先讀熟事件處理
01/18 01:46, 3F
文章代碼(AID): #17YW6bS9 (C_Sharp)
討論串 (同標題文章)
文章代碼(AID): #17YW6bS9 (C_Sharp)