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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:45:30+00:00 2026-06-06T00:45:30+00:00

I am new at ASP.net and VB.net.So i Learn from book beginning ASP.Net 3.5

  • 0

I am new at ASP.net and VB.net.So i Learn from book beginning ASP.Net 3.5 in VB 2008

the code on select.aspx.vb are

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration


Partial Public Class _Select
    Inherits System.Web.UI.Page

    Private Conn As String = WebConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString

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

        If Not Page.IsPostBack Then
            FillAuthorList()
        End If
    End Sub

    Private Sub FillAuthorList()
        lstAuthor.Items.Clear()
        ' Define the Select statement.
        ' Three pieces of information are needed: the unique id
        ' and the first and last name.
        Dim selectSQL As String = "SELECT Nama_Depan, Nama_Belakang, ID FROM Employee"
        ' Define the ADO.NET objects.
        Dim con As New SqlConnection(Conn)
        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("Nama_Depan") & ", " & reader("Nama_Belakang")
                newItem.Value = reader("ID").ToString()
                lstAuthor.Items.Add(newItem)
            Loop
            reader.Close()
        Catch err As Exception
            lblResults.Text = "Error reading list of names."
            lblResults.Text &= err.Message
        Finally
            con.Close()
        End Try
    End Sub

    Protected Sub lstAuthor_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lstAuthor.SelectedIndexChanged
        ' Create a Select statement that searches for a record
        ' matching the specific author ID from the Value property.
        Dim selectSQL As String
        selectSQL = "SELECT * FROM Employee "
        selectSQL &= "WHERE ID='" & lstAuthor.SelectedItem.Value & "' "
        ' Define the ADO.NET objects.
        Dim con As New SqlConnection(Conn)
        Dim cmd As New SqlCommand(selectSQL, con)
        Dim reader As SqlDataReader
        ' Try to open database and read information.
        Try
            con.Open()
            reader = cmd.ExecuteReader()
            reader.Read()

            ' Build a string with the record information,
            ' and display that in a label.
            Dim sb As New StringBuilder()
            sb.Append("<b>")
            sb.Append(reader("Nama_Depan"))
            sb.Append(", ")
            sb.Append(reader("Nama_Belakang"))
            sb.Append("</b><br />")

            lblResults.Text = sb.ToString()
            reader.Close()
        Catch err As Exception
            lblResults.Text = "Error getting author. "
            lblResults.Text &= err.Message
        Finally
            con.Close()
        End Try
    End Sub
End Class

And the select.aspx are

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Select.aspx.vb" Inherits="connn._Select" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ListBox ID="lstAuthor" runat="server" ></asp:ListBox>
        <br />

    <asp:Label ID="lblResults" runat="server">


    </asp:Label>
    </div>
    </form>
</body>
</html>

I am trying when select Listbox with ID=”lstAuthor” the label box will pass the value but it failed to show.

  • 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-06T00:45:32+00:00Added an answer on June 6, 2026 at 12:45 am

    Set True to AutoPostBack property:

    <asp:ListBox ID="lstAuthor" 
                 runat="server"  
                 AutoPostBack="True" ></asp:ListBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm new in asp.net mvc 2. I'm trying to list all data from one
i'm new to asp.net and i'm writing some code to learn about arraylist al.Add((string)asfsaf);
I am starting a new project and was going to use it learn asp.net
I’m new to asp.net and the mvc framework and I’m trying to learn by
I am trying to learn Asp.net mvc. I know its different from forms and
I'm new to ASP.NET and have just starting to learn ASP.NET MVC 3. I've
I am new to asp.net and I am trying to learn Linq to SQL.
Im new to ASP.NET MVC, trying to learn the basics. Im now trying to
just trying to learn asp.net i am able to login and redirect to default.aspx.
I'm trying to learn the new ASP .NET MVC framework and would like to

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.