为什么确认删除不执行 高分求解(100)
在gridview中用向导加入了一个commandfield 的删除按钮。 用的buttontype是image。
后台代码如下
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack() Then
bindDataGrid()
End If
End Sub
Private Sub bindDataGrid()
Dim indexs(0 To 0) As String
indexs(0) = "公告ID "
cnn = New SqlConnection(strCnn)
cnn.Open()
Dim cmdStr As String = "select * from 技术公告 order by 发布日期 desc "
dad = New SqlDataAdapter(cmdStr, cnn)
dst = New DataSet()
dad.Fill(dst, "all ")
GridView1.DataSource = dst.Tables( "all ").DefaultView()
GridView1.DataKeyNames = indexs
GridView1.DataBind()
cnn.Close()
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
If (e.Row.RowState = DataControlRowState.Normal Or e.Row.RowState = DataControlRowState.Alternate) Then
Dim aa As WebControls.ImageButton
Dim returnValue As Type
returnValue = e.Row.Cells(1).Controls(0).GetType()
aa = e.Row.Cells(1).Controls(0)
aa.Attributes.Add( "onclick ", "return confirm( '你