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 7796247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:18:55+00:00 2026-06-01T23:18:55+00:00

Afternoon All, I have a dropdown list which extracts data from my SQL database

  • 0

Afternoon All,

I have a dropdown list which extracts data from my SQL database and gives the users two options to choose from (Weekly / Monthly). The database has an ID for each of these. Weekly is set to 1 and Monthly is set to 2. This drop down is linked to a gridview which extracts / displays the data based on the selected item. All of this works perfectly fine.

This issue i have is that i want to add some code in my Page_ load event to populate a text box with the selected item. I would also like to set the dropdownlist as default to weekly when a users access thie page. i thought that the two following bits of code would work but i get the messege ‘Input string was not in a correct format’.

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    'This works fine
    lblTodaysDate.Text = GetDate()


    'I thought i could complete an If Statement to get the text box to work.
    If DropDownList1.SelectedValue = 1 Then
        txtMeeting.Text = "SMC Weekly Meeting"
    Else
        txtMeeting.Text = "SMC Monthly Meeting"
    End If


End Sub

Im new to .net but have read that i might need to convert my int to a string?

Any help in advance would be much appriechiated.

Regards
Betty.

  • 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-06-01T23:18:56+00:00Added an answer on June 1, 2026 at 11:18 pm

    First check that your value is numeric, if it is, then convert it to an integer, and compare it to 1:

    If IsNumeric(DropDownList1.SelectedValue) AndAlso CInt(DropDownList1.SelectedValue)=1
        txtMeeting.Text = "SMC Weekly Meeting"
    Else
        txtMeeting.Text = "SMC Monthly Meeting"
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Afternoon All, I have two tables in my SQL Server 2005 DB, Main
Afternoon All, I have a stored procedure in an SQL 2005 database named GasNominationsRawData_Insert.
Afternoon, I am trying have an HTML file containing a frameset which contains two
Good afternoon all, I have a class which looks like this: public class Grapheme
Good afternoon to all, I have this scenario: I am using SQL Server 'BulkInsert'
Good afternoon all. I have a page that displays data in a gridview based
Afternoon all I have a lovely webservice call that brings back a list, we'll
Afternoon All I have some data - var searchwithin = [ {id:clearwithin, type:button}, {id:search_radius,
Afternoon all. A very simple one for you today from thicky Rich. I have
Afternoon, Lets say I have gather a random selection of users: User.find(:all, :limit =>

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.