We have a a few button fields in our gridview and we'd like to be able to have it prompt user to confirm before continuing. Seen a couple Javascripts that do it onclick events but would like to do right in vb code if possible. Here is the asp code for one of the buttons in our gridview:
<asp:ButtonField ButtonType="Button" CommandName="Complete"
HeaderText="" ShowHeader="False" Text="Complete" />
And the VB code behind:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
'Would like to do some kind of msgbox to confirm that they want to continue
Dim currentCommand As String = e.CommandName
If currentCommand = "Complete" Then
Dim currentRowIndex As Integer = Int32.Parse(e.CommandArgument
Dim PageID As String = GridView1.Rows(currentRowIndex).Cells(0).Text
Dim connSQL As SqlConnection = New SqlConnection("Initial Catalog=productionx;Data Source=sqlserverx;Integrated Security=False; user id=xxx;password=yyyyyyyy; Connect Timeout=60"
connSQL.Open()
Dim sqlSP As String
sqlSP = "exec spWebCircularCustomerCompleteTemplate @PageID =" & PageID
Dim cmdSP As New SqlCommand(sqlSP, connSQL)
Dim rdrSP As SqlDataReader = cmdSP.ExecuteReader()
rdrSP.Read()
rdrSP.Close()
connSQL.Close()
Response.Redirect("../Circulars/EditCircularPage.aspx")
End If
End Sub
Thanks,
Joe
<asp:ButtonField ButtonType="Button" CommandName="Complete"
HeaderText="" ShowHeader="False" Text="Complete" />
And the VB code behind:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
'Would like to do some kind of msgbox to confirm that they want to continue
Dim currentCommand As String = e.CommandName
If currentCommand = "Complete" Then
Dim currentRowIndex As Integer = Int32.Parse(e.CommandArgument
Dim PageID As String = GridView1.Rows(currentRowIndex).Cells(0).Text
Dim connSQL As SqlConnection = New SqlConnection("Initial Catalog=productionx;Data Source=sqlserverx;Integrated Security=False; user id=xxx;password=yyyyyyyy; Connect Timeout=60"
connSQL.Open()
Dim sqlSP As String
sqlSP = "exec spWebCircularCustomerCompleteTemplate @PageID =" & PageID
Dim cmdSP As New SqlCommand(sqlSP, connSQL)
Dim rdrSP As SqlDataReader = cmdSP.ExecuteReader()
rdrSP.Read()
rdrSP.Close()
connSQL.Close()
Response.Redirect("../Circulars/EditCircularPage.aspx")
End If
End Sub
Thanks,
Joe