Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 833075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:27:40+00:00 2026-05-15T04:27:40+00:00

I am using ASP.NET forms version 3.5 in VB I have a dropdownlist that

  • 0

I am using ASP.NET forms version 3.5 in VB

I have a dropdownlist that is filled with data from a DB with a list of countries

The code for the dropdown list is

         <label class="ob_label">
            <asp:DropDownList ID="lstCountry" runat="server" CssClass="ob_forminput">
            </asp:DropDownList>
         Country*</label>

And the code that the list is

 Dim selectSQL As String = "exec dbo.*******************"

    ' Define the ADO.NET objects.
    Dim con As New SqlConnection(connectionString)
    Dim cmd As New SqlCommand(selectSQL, con)
    Dim reader As SqlDataReader

    ' Try to open database and read information.
    Try
        con.Open()
        reader = cmd.ExecuteReader()

        ' For each item, add the author name to the displayed
        ' list box text, and store the unique ID in the Value property.

        Do While reader.Read()
            Dim newItem As New ListItem()
            newItem.Text = reader("AllSites_Countries_Name")
            newItem.Value = reader("AllSites_Countries_Id")
            CType(LoginViewCart.FindControl("lstCountry"), DropDownList).Items.Add(newItem)
        Loop
        reader.Close()

        CType(LoginViewCart.FindControl("lstCountry"), DropDownList).SelectedValue = 182

    Catch Err As Exception
        Response.Redirect("~/error-on-page/")

        MailSender.SendMailMessage("*********************", "", "", OrangeBoxSiteId.SiteName & " Error Catcher", "<p>Error in sub FillCountry</p><p>Error on page:" & HttpContext.Current.Request.Url.AbsoluteUri & "</p><p>Error details: " & Err.Message & "</p>")
        Response.Redirect("~/error-on-page/")
    Finally
        con.Close()
    End Try

When the form is submitted an error occurs which says that the string “” cannot be converted to the datatype integer. For some reason the dropdownlist is posting “” rather than the value for the selected country.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:27:41+00:00Added an answer on May 15, 2026 at 4:27 am

    2 things I can think of.

    1) Are you sure the SQL is returning something that has the value of 182 ?

    2) Are you rebuilding the Drop-down list on Postback ? as it’s dynamic you’ll have too else it won’t know which value you selected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET 4 Web Forms app that is using URL Routing. I
I'm developing an ASP.NET forms webapplication using C#. I have a method which creates
I am building a Web Application using asp.net (C#). I come from windows forms
I have a ASP.NET Web Forms application and I'm using some dynamic controls in
I am working on an ASP.NET web forms application that is using Forms Authentication.
We have an ASP.NET application that uses Forms Auth. When users log in, a
First some background: I have a website using ASP.NET web forms + jQuery 1.6.4
I am using asp.net forms authentication, membership provider and role provider. You can refer
I am using ASP.NET Web Forms/C# . I am having this function in my
I am using Asp.Net/C# in my project.I am using Forms Authentication .Currently I call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.