Hi
I have main form and modal form. Modal form is updating users table on sql server. After updating Reporter Name drop down list should update the added record. But it is not working when call fillreporter() sub procedure
Please help me to fix this
Thanks & Regards,
Harinda
'------------------------ Add New user modal popup-----------------
Protected Sub RegisterUser(sender As Object, e As EventArgs) Handles CmdCreateNewUser.Click
Dim userId As Integer = 0
'Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
' Using cn As New SqlConnection(constr)
Try
If (Page.IsValid) Then
cn.Open()
Dim cmd As New SqlCommand("Insert_User")
Dim da As New SqlDataAdapter()
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@UserType", ddusertype.Text.Trim())
cmd.Parameters.AddWithValue("@FullName", txtFullName.Text.Trim())
cmd.Parameters.AddWithValue("@Email", txtEmail.Text.Trim())
cmd.Parameters.AddWithValue("@Password", GetMD5Hash(txtPassword.Text.Trim()))
cmd.Parameters.AddWithValue("@UserGroup", ddusergroup.Text.Trim())
cmd.Parameters.AddWithValue("@Site", ddsiteadduser.Text.Trim())
cmd.Parameters.AddWithValue("@ReportingManager", ddReportingManager.Text.Trim())
cmd.Parameters.AddWithValue("@Department", dddepartmentadduser.Text.Trim())
cmd.Parameters.AddWithValue("@Mobile", txtMobile.Text.Trim())
cmd.Parameters.AddWithValue("@EmailNotificationGroup", EmailNotificationGroup.Text.Trim())
cmd.Connection = cn
userId = Convert.ToInt32(cmd.ExecuteScalar())
Dim message As String = String.Empty
Select Case userId
Case -1
message = "Full Name already exists.\Please choose a different username."
Exit Select
Case -2
message = "Supplied email address has already been used."
Exit Select
Case Else
message = "User Registration successful.\nUser Id: " + userId.ToString()
Exit Select
End Select
ClientScript.RegisterStartupScript([GetType](), "alert", (Convert.ToString("alert('") & message) + "');", True)
End If
Catch ex As SqlException
MsgBox(ex.Message)
Catch err As System.Exception
MsgBox(err.Message)
Finally
cn.Close()
FillPersonInvolved()
FillReporters()
End Try
End Sub
Public Sub FillReporters()
Try
cn.Open()
If Not Me.IsPostBack Then
Dim dal As SqlDataAdapter
Dim dsl As DataSet
Dim dvl As DataView
dal = New SqlDataAdapter("select * from users1 order by FullName desc", cn)
dsl = New DataSet
dal.Fill(dsl, "users1")
dvl = New DataView(dsl.Tables(0))
dvl.Sort = "FullName"
ddreporterName.DataSource = dvl
ddreporterName.DataTextField = "FullName"
ddreporterName.DataValueField = "FullName"
ddreporterName.DataBind()
ddreporterName.Items.Insert(0, New ListItem("", ""))
End If
Catch ex As SqlException
'MsgBox(ex.Message)
Dim message As String = (ex.Message)
Dim script As String = "window.onload = function(){ alert('"
script &= message
script &= "')};"
ClientScript.RegisterStartupScript(Me.GetType(), "SuccessMessage", script, True)
Catch err As System.Exception
' MsgBox(err.Message)
Dim message As String = (err.Message)
Dim script As String = "window.onload = function(){ alert('"
script &= message
script &= "')};"
ClientScript.RegisterStartupScript(Me.GetType(), "SuccessMessage", script, True)
Finally
cmd = Nothing
cn.Close()
End Try
End Sub