Click here to Skip to main content
15,917,176 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionhelp with displaying hierarchical data in treeview in Visual Basic 2005 Pin
kim67830-Mar-10 21:10
kim67830-Mar-10 21:10 
QuestionNewbie to VB Pin
willwilco30-Mar-10 15:10
willwilco30-Mar-10 15:10 
AnswerRe: Newbie to VB Pin
_Damian S_30-Mar-10 16:05
professional_Damian S_30-Mar-10 16:05 
AnswerRe: Newbie to VB Pin
Wayne Gaylard30-Mar-10 20:38
professionalWayne Gaylard30-Mar-10 20:38 
GeneralRe: Newbie to VB Pin
willwilco31-Mar-10 13:41
willwilco31-Mar-10 13:41 
AnswerRe: Newbie to VB Pin
The Man from U.N.C.L.E.31-Mar-10 7:07
The Man from U.N.C.L.E.31-Mar-10 7:07 
GeneralRe: Newbie to VB Pin
willwilco31-Mar-10 13:42
willwilco31-Mar-10 13:42 
QuestionTwo RadioButtonList.SelectedIndex Values Changed Simultaneously - What am I Doing Wrong? Pin
johnaparker30-Mar-10 11:11
johnaparker30-Mar-10 11:11 
I'm using Visual Studio 2008 to develop a web site for my daughter's softball league. In one page I have two RadioButtonLists in the same panel in their own table cells. I programatically build the RBLs and determine the initial selected index values for each. The behavior I'm seeing is as follows:

1. I sucessfully change the first selected index from its cleared
state (-1) to the value I calculated. The second RBL remains in
its clear state (as it should).
2. I then set the second RBL's selected index. While its value is
correctly set, the first RBL's selected index is also altered
to the same value simulataneously.

I've stepped through with the VS debugger and watched these two steps occur as described.

Is this a known faux pas on my part? If so what have I done wrong?

Otherwise, has anyone else seen similar behavior?

I'm not sure what to include here so I'll probably provide too much of some detail and not enough of other, but I'll gladly provide the entire aspx file (imbedded VB script plus a common function VB scrip "include") and/or screen captures of the variable states as I stepped through the code, if any of these would be of use.

Please don't make fun of my choice of style!

PLEASE NOTE: Even though I'm including the related event handler routines, the erroneous behavior occurs on page load before any user selections are made.

Detail below.

Thanks in advance,

John

#########################################################################################

Page Content:

<tr>
    <td>&nbsp;</td>
    <td align="left">
        <asp:RadioButtonList ID="hTeamNameRBL" runat="server" Enabled="False" OnSelectedIndexChanged="selectedHomeTeamChanged" AutoPostBack="True"></asp:RadioButtonList>
    </td>
    <td>&nbsp;</td>
    <td align="left">
        <asp:RadioButtonList ID="aTeamNameRBL" runat="server" Enabled="False" OnSelectedIndexChanged="selectedAwayTeamChanged" AutoPostBack="True"></asp:RadioButtonList>
    </td>
    <td>&nbsp;</td>
    <td align="left" valign="top">
        <asp:RadioButtonList ID="fieldRBL" runat="server" Width="200px" style="text-align:left;" Enabled="False" OnSelectedIndexChanged="selectedFieldChanged" AutoPostBack="True"></asp:RadioButtonList>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:TextBox ID="otherField" runat="server" Enabled="false" OnTextChanged="otherFieldTextChanged" AutoPostBack="True"></asp:TextBox>
    </td>
    <td>&nbsp;</td>
</tr>


#########################################################################################

RadioButton Contructor Routine:

PLEASE NOTE:: The common function call...

myCommonVB.getTeamNamesByDiv(myYear, division, teamNames, teamNumbers, teamLetters, errEncountered, errDetail)

Takes (ByVal) integer "year" and "division" values and returns (ByRef) string arrays of teamNames, teamNumbers and teamLetters (pulled from a database), as well as error information if any.

Sub buildTeamRBL(ByVal division As Integer, Optional ByVal myYear As Integer = 2010)

    Dim teamNames As String() = Nothing
    Dim teamNumbers As String() = Nothing
    Dim teamLetters As String() = Nothing

    Dim lItem As New ListItem()
    Dim tnLen As Integer = 0

    Dim hTeamSelected As Integer = -1
    Dim aTeamSelected As Integer = -1

    hTeamNameRBL.Enabled = True
    aTeamNameRBL.Enabled = True
    hTeamNameRBL.Items.Clear()
    aTeamNameRBL.Items.Clear()
    hTeamNameRBL.ClearSelection()
    aTeamNameRBL.ClearSelection()

    myCommonVB.getTeamNamesByDiv(myYear, division, teamNames, teamNumbers, teamLetters, errEncountered, errDetail)

    If Not errEncountered Then
        tnLen = teamNames.GetUpperBound(0)
        For i As Integer = 0 To tnLen - 1
            lItem = New ListItem()
            lItem.Text = teamNames.GetValue(i)
            lItem.Value = lItem.Text
            aTeamNameRBL.Items.Add(lItem)
            If lItem.Text.Equals(aTeamName) Then
                aTeamSelected = i
                aTeamNumber = teamNumbers(i)
                aTeamLetter = teamLetters(i)
            End If
            hTeamNameRBL.Items.Add(lItem)
            If lItem.Text.Equals(hTeamName) Then
                hTeamSelected = i
                hTeamNumber = teamNumbers(i)
                hTeamLetter = teamLetters(i)
            End If
        Next
        aTeamNameRBL.SelectedIndex = aTeamSelected
        hTeamNameRBL.SelectedIndex = hTeamSelected
    Else
        debug.Text += errDetail
    End If
End Sub

#########################################################################################

OnSelectedIndexChanged routines:

FYI: The following two ensure the alternate RBL doesn't have the same selected value.

Sub selectedHomeTeamChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim orgAteamSelectedIndex As Integer = aTeamNameRBL.SelectedIndex
    Dim newHteamSelectedIndex As Integer = hTeamNameRBL.SelectedIndex

    For i As Integer = 0 To teamNames.GetUpperBound(0) - 1
        aTeamNameRBL.SelectedIndex = i
        aTeamNameRBL.SelectedItem.Enabled = True
    Next
    aTeamNameRBL.SelectedIndex = newHteamSelectedIndex
    aTeamNameRBL.SelectedItem.Enabled = False
    If Not orgAteamSelectedIndex = -1 Then
        aTeamNameRBL.SelectedIndex = orgAteamSelectedIndex
    Else
        aTeamNameRBL.ClearSelection()
    End If
    seeIfEnablingSubmit()
End Sub

Sub selectedAwayTeamChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim orgHteamSelectedIndex As Integer = hTeamNameRBL.SelectedIndex
    Dim newAteamSelectedIndex As Integer = aTeamNameRBL.SelectedIndex

    For i As Integer = 0 To teamNames.GetUpperBound(0) - 1
        hTeamNameRBL.SelectedIndex = i
        hTeamNameRBL.SelectedItem.Enabled = True
    Next
    hTeamNameRBL.SelectedIndex = newAteamSelectedIndex
    hTeamNameRBL.SelectedItem.Enabled = False
    If Not orgHteamSelectedIndex = -1 Then
        hTeamNameRBL.SelectedIndex = orgHteamSelectedIndex
    Else
        hTeamNameRBL.ClearSelection()
    End If
    seeIfEnablingSubmit()
End Sub

AnswerRe: Two RadioButtonList.SelectedIndex Values Changed Simultaneously - What am I Doing Wrong? Pin
pdnet1-Apr-10 21:46
pdnet1-Apr-10 21:46 
GeneralRe: Two RadioButtonList.SelectedIndex Values Changed Simultaneously - What am I Doing Wrong? Pin
johnaparker3-Apr-10 4:28
johnaparker3-Apr-10 4:28 
Questionhow can i catch form event keydown if my form has datagridview control ? Pin
xingselex30-Mar-10 6:36
xingselex30-Mar-10 6:36 
AnswerRe: how can i catch form event keydown if my form has datagridview control ? Pin
Abhinav S30-Mar-10 6:48
Abhinav S30-Mar-10 6:48 
AnswerRe: how can i catch form event keydown if my form has datagridview control ? Pin
dan!sh 30-Mar-10 6:49
professional dan!sh 30-Mar-10 6:49 
QuestionVB 2008 DataGridView Pin
Filippo197430-Mar-10 5:46
Filippo197430-Mar-10 5:46 
AnswerRe: VB 2008 DataGridView Pin
dan!sh 30-Mar-10 6:12
professional dan!sh 30-Mar-10 6:12 
AnswerRe: VB 2008 DataGridView Pin
Filippo197430-Mar-10 6:18
Filippo197430-Mar-10 6:18 
GeneralRe: VB 2008 DataGridView Pin
Filippo197430-Mar-10 10:12
Filippo197430-Mar-10 10:12 
GeneralRe: VB 2008 DataGridView Pin
Sebastian Br.31-Mar-10 21:37
Sebastian Br.31-Mar-10 21:37 
AnswerRe: VB 2008 DataGridView Pin
William Winner30-Mar-10 11:04
William Winner30-Mar-10 11:04 
AnswerRe: VB 2008 DataGridView Pin
William Winner30-Mar-10 11:08
William Winner30-Mar-10 11:08 
QuestionCreate autowidth() Property Pin
nyt197230-Mar-10 1:32
professionalnyt197230-Mar-10 1:32 
GeneralRe: Create autowidth() Property Pin
DaveAuld30-Mar-10 4:35
professionalDaveAuld30-Mar-10 4:35 
AnswerRe: Create autowidth() Property Pin
DaveAuld30-Mar-10 11:31
professionalDaveAuld30-Mar-10 11:31 
AnswerRe: Create autowidth() Property Pin
Anubhava Dimri30-Mar-10 20:07
Anubhava Dimri30-Mar-10 20:07 
AnswerRe: Create autowidth() Property Pin
nyt197230-Mar-10 20:27
professionalnyt197230-Mar-10 20:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.