Back to
swartzentruber.net
 

Code Examples in VB.NET (Framework 1.1)

Code Samples Home


cachemanager

createlinkspagewithxml

hideorshowaddnew

lookupusercontrolwithevents

lookupusercontrolwithevents2

looplistboxforselected

tourcalendarinternational

tourcalendarwithdetail

tourcalendarwithdetail2

tourcalendarwithdetail3

usercontrol_sessionview

usertablestoarraylist_via_sqldmo

Loop Through Listbox Collecting Selected Item Values
Summary & Comments

This simply allows you to get all the selected items from a multi-select enabled listbox.

ASPX Code
To be supplied
VB.NET Codebehind Code
Protected Sub btnNew_Click_ListBox(ByVal sender As Object, ByVal e As EventArgs)

        Dim objDT As New D_MyTable()
        Dim MainID As Integer
        Dim RelatedID As Integer = CType(ddNewRelated.SelectedItem.Value, Integer)

        If (MainID = 0) Then
            txtMsg.Text = "Cannot add new record without selecting a {Main}."
            Exit Sub
        End If

        Dim listRow As ListItem

        For Each listRow In lbxNewRelated.Items
            If listRow.Selected Then
                RelatedID = CInt(listRow.Value)
                objDT.InsertRow(MainID, RelatedID, iAuthorID)
                listRow.Selected = False
            End If
        Next

        ddRelated.SelectedIndex = 0
        BindGrid()

    End Sub

© 1999-2008 swartzentruber.net