Dim strConn As String = ConfigurationManager.ConnectionStrings("connectionString").ConnectionString
Using sqlConn As New SqlConnection(strConn)
Using sqlCmd As New SqlCommand()
sqlCmd.CommandText = "SELECT departmentname FROM DepartmentMembership where sid='" & Session("empId") & "' order by ordby"
sqlCmd.Connection = sqlConn
sqlConn.Open()
Dim da As New SqlDataAdapter(sqlCmd)
Dim dt As New DataTable()
da.Fill(dt)
EmpDept.DataSource = dt
EmpDept.DataValueField = "departmentname"
EmpDept.DataTextField = "departmentname"
EmpDept.DataBind()
sqlConn.Close()
End Using
End Using
I want if dropdownlist is emply then show msgbox("Please add data")
I want if dropdownlist is emply then show msgbox("Please add data")
This requirement is not possible in a web application because the MsgBox will display on the web server not in the browser. Anyway, you just need to write code that checks if the SQL results set is empty then prompt the user to add data using standard
server controls. For example a label.
If you are building a Windows Application then you are in the wrong support forum.
Member
22 Points
82 Posts
DropDownList
Feb 19, 2020 08:32 AM|kafsar|LINK
I have the following code to fill dropdownlist:
I want if dropdownlist is emply then show msgbox("Please add data")
Thanks
All-Star
53101 Points
23659 Posts
Re: DropDownList
Feb 19, 2020 02:05 PM|mgebhard|LINK
This requirement is not possible in a web application because the MsgBox will display on the web server not in the browser. Anyway, you just need to write code that checks if the SQL results set is empty then prompt the user to add data using standard server controls. For example a label.
If you are building a Windows Application then you are in the wrong support forum.
Member
22 Points
82 Posts
Re: DropDownList
Feb 19, 2020 02:42 PM|kafsar|LINK
Thanks for reply..
Is possible to insert word "Add data" in blank dropdownlist if it is empty?
Member
22 Points
82 Posts
Re: DropDownList
Feb 19, 2020 03:46 PM|kafsar|LINK
Issue Solved..