|
-
Feb 3rd, 2009, 10:11 PM
#1
Thread Starter
Hyperactive Member
[02/03] Msgbox sequence problem, thanks for help :-)
Hi all,
I'm newbie of ASP.net , I had create a datagrid which enabled user edit record within the datagrid. Before the user update the record into the database the page will calling a confirm messagebox from msgbox.dll to get confirmation from user. If the user click on OK then the update statement will be proceed and prompt a message to indicate update completed.
But now my issue is the sequence of messagebox is wrong in which it will execute the update statement. Afterward, the confirm alert messagebox.
Anyone know the reason or solution?
I posted my code behind.
ASP Code:
Private Sub dgSchoolName_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgSchoolName.UpdateCommand
Dim myds As New DataSet
Dim myDT As New DataTable
Dim mydr As DataRow
Dim strsql As String, strUpdateSqL(0) As String
Dim dgTxtSchoolName As TextBox = CType(e.Item.Cells(2).FindControl("txtSchoolName"), TextBox)
Dim dgSchoolNo As String = Convert.ToString(e.Item.Cells(1).Text)
Dim getSchoolName As String = dgTxtSchoolName.Text
strsql = "SELECT SchoolName From SchoolName WHERE SchoolNo = '" & dgSchoolNo & "'"
Try
MsgBox2.confirm("Do you want to update for School No " + e.Item.Cells(1).Text + " ?", "Confirmation")
If (IsPostBack) Then
If Request.Form("Confirmation") = 1 Then
Request.Form("Confirmation").Replace("1", "0")
End If
End If
myds = myC.GetRecordSet(strsql, "Greenwave", "SchoolName", "GreenWave.xml")
myDT = myds.Tables("SchoolName")
If myDT.Rows.Count = 0 Then
MsgBox1.alert("Record Not Found, Update Failed")
Me.dgSchoolName.EditItemIndex = -1
Exit Sub
Else
If dgTxtSchoolName.Text = vbNullString Then
MsgBox1.alert("School Name cannot be blank")
Exit Sub
Else
strUpdateSqL(0) = "UPDATE SchoolName" & _
" SET SchoolName = '" & getSchoolName & "'" & _
" WHERE SchoolNo = '" & dgSchoolNo & "'"
If (myC.Ins_Update_DeleteRecord(strUpdateSqL, "Greenwave", "GreenWave.xml")) = True Then
MsgBox1.alert("Update Completed")
Else
MsgBox1.alert("Failed to Update")
End If
End If
End If
Me.dgSchoolName.EditItemIndex = -1
dgSchoolName.DataBind()
Catch ex As Exception
End Try
End Sub
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|