Home All Groups Group Topic Archive Search About

radiobuttonlist.selectedIndex always -1.........

Author
10 Feb 2006 4:47 PM
astropup
I'm trying to get the selected button in a radiobutton list....but the
selectedindex is always -1.    Any ideas what i'm doing wrong?
Thanks!

==================================
I've included the code that loads the radiobuttonList here:
==================================
Private Sub loadrblCanRpts()

Dim cnn As New SqlClient.SqlConnection
Dim cmd As New SqlClient.SqlCommand
Dim rbl As RadioButtonList = Me.rblCannedRpts
Dim sStr As String

cnn.ConnectionString = gcsCnnStr
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "_sp_getCannedReports"
cmd.Connection = cnn

Try
    cnn.Open()
    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
    While rdr.Read
        Dim itm As New ListItem(rdr.Item("cannedName"), rdr.Item("spnames"))
        rbl.Items.Add(itm)
    End While
    rdr.Close()
    cnn.Close()
Catch ex As Exception
    Stop
End Try

End Sub

==================================
The code that looks for the selected button is here:
==================================

Private Sub loadHashTable(ByVal acontainer As Object)
    'loop thru all controls on page - stuff all checkboxes or radio button
that are not null
    'into hashtable

    Dim ctrl As Control
    For Each ctrl In acontainer.controls
        If ctrl.HasControls Then
            Call loadHashTable(ctrl)
        End If
        If TypeOf ctrl Is CheckBox Then
            With ctrl
                If CType(ctrl, CheckBox).Checked Then
                    mHT.Add(ctrl.ID, ctrl.ID)
                End If
            End With
        ElseIf TypeOf ctrl Is RadioButtonList Then
            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
                 Stop <<< never get to this point...selectedIndex is
always -1 !>>>
            End If
        End If
Next

Author
10 Feb 2006 4:52 PM
Teemu Keiski
Hi,

does the initial populating happen inside If Not Page.IsPostback check? At
which point do you check for the selection e.g in page_load, button_click
etc?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Show quoteHide quote
"astropup" <astro***@mn.rr.com> wrote in message
news:ts3Hf.551$CV.269@tornado.rdc-kc.rr.com...
>
> I'm trying to get the selected button in a radiobutton list....but the
> selectedindex is always -1.    Any ideas what i'm doing wrong?
> Thanks!
>
> ==================================
> I've included the code that loads the radiobuttonList here:
> ==================================
> Private Sub loadrblCanRpts()
>
> Dim cnn As New SqlClient.SqlConnection
> Dim cmd As New SqlClient.SqlCommand
> Dim rbl As RadioButtonList = Me.rblCannedRpts
> Dim sStr As String
>
> cnn.ConnectionString = gcsCnnStr
> cmd.CommandType = CommandType.StoredProcedure
> cmd.CommandText = "_sp_getCannedReports"
> cmd.Connection = cnn
>
> Try
>    cnn.Open()
>    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>    While rdr.Read
>        Dim itm As New ListItem(rdr.Item("cannedName"),
> rdr.Item("spnames"))
>        rbl.Items.Add(itm)
>    End While
>    rdr.Close()
>    cnn.Close()
> Catch ex As Exception
>    Stop
> End Try
>
> End Sub
>
> ==================================
> The code that looks for the selected button is here:
> ==================================
>
> Private Sub loadHashTable(ByVal acontainer As Object)
>    'loop thru all controls on page - stuff all checkboxes or radio button
> that are not null
>    'into hashtable
>
>    Dim ctrl As Control
>    For Each ctrl In acontainer.controls
>        If ctrl.HasControls Then
>            Call loadHashTable(ctrl)
>        End If
>        If TypeOf ctrl Is CheckBox Then
>            With ctrl
>                If CType(ctrl, CheckBox).Checked Then
>                    mHT.Add(ctrl.ID, ctrl.ID)
>                End If
>            End With
>        ElseIf TypeOf ctrl Is RadioButtonList Then
>            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>                 Stop <<< never get to this point...selectedIndex is
> always -1 !>>>
>            End If
>        End If
> Next
>
>
>
>
>
>
>
>
Author
10 Feb 2006 7:47 PM
astropup
no - but I've added that and it makes no difference...

-)

Show quoteHide quote
"Teemu Keiski" <jot***@aspalliance.com> wrote in message
news:e56%23EKmLGHA.208@tk2msftngp13.phx.gbl...
> Hi,
>
> does the initial populating happen inside If Not Page.IsPostback check? At
> which point do you check for the selection e.g in page_load, button_click
> etc?
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
> "astropup" <astro***@mn.rr.com> wrote in message
> news:ts3Hf.551$CV.269@tornado.rdc-kc.rr.com...
>>
>> I'm trying to get the selected button in a radiobutton list....but the
>> selectedindex is always -1.    Any ideas what i'm doing wrong?
>> Thanks!
>>
>> ==================================
>> I've included the code that loads the radiobuttonList here:
>> ==================================
>> Private Sub loadrblCanRpts()
>>
>> Dim cnn As New SqlClient.SqlConnection
>> Dim cmd As New SqlClient.SqlCommand
>> Dim rbl As RadioButtonList = Me.rblCannedRpts
>> Dim sStr As String
>>
>> cnn.ConnectionString = gcsCnnStr
>> cmd.CommandType = CommandType.StoredProcedure
>> cmd.CommandText = "_sp_getCannedReports"
>> cmd.Connection = cnn
>>
>> Try
>>    cnn.Open()
>>    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>    While rdr.Read
>>        Dim itm As New ListItem(rdr.Item("cannedName"),
>> rdr.Item("spnames"))
>>        rbl.Items.Add(itm)
>>    End While
>>    rdr.Close()
>>    cnn.Close()
>> Catch ex As Exception
>>    Stop
>> End Try
>>
>> End Sub
>>
>> ==================================
>> The code that looks for the selected button is here:
>> ==================================
>>
>> Private Sub loadHashTable(ByVal acontainer As Object)
>>    'loop thru all controls on page - stuff all checkboxes or radio button
>> that are not null
>>    'into hashtable
>>
>>    Dim ctrl As Control
>>    For Each ctrl In acontainer.controls
>>        If ctrl.HasControls Then
>>            Call loadHashTable(ctrl)
>>        End If
>>        If TypeOf ctrl Is CheckBox Then
>>            With ctrl
>>                If CType(ctrl, CheckBox).Checked Then
>>                    mHT.Add(ctrl.ID, ctrl.ID)
>>                End If
>>            End With
>>        ElseIf TypeOf ctrl Is RadioButtonList Then
>>            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>                 Stop <<< never get to this point...selectedIndex is
>> always -1 !>>>
>>            End If
>>        End If
>> Next
>>
>>
>>
>>
>>
>>
>>
>>
>
>
Author
10 Feb 2006 8:34 PM
Teemu Keiski
So,

how's the entire page's code like?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Show quoteHide quote
"astropup" <astro***@mn.rr.com> wrote in message
news:q56Hf.1233$xZ4.764@tornado.rdc-kc.rr.com...
>
> no - but I've added that and it makes no difference...
>
> -)
>
> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
> news:e56%23EKmLGHA.208@tk2msftngp13.phx.gbl...
>> Hi,
>>
>> does the initial populating happen inside If Not Page.IsPostback check?
>> At which point do you check for the selection e.g in page_load,
>> button_click etc?
>>
>> --
>> Teemu Keiski
>> ASP.NET MVP, AspInsider
>> Finland, EU
>> http://blogs.aspadvice.com/joteke
>>
>> "astropup" <astro***@mn.rr.com> wrote in message
>> news:ts3Hf.551$CV.269@tornado.rdc-kc.rr.com...
>>>
>>> I'm trying to get the selected button in a radiobutton list....but the
>>> selectedindex is always -1.    Any ideas what i'm doing wrong?
>>> Thanks!
>>>
>>> ==================================
>>> I've included the code that loads the radiobuttonList here:
>>> ==================================
>>> Private Sub loadrblCanRpts()
>>>
>>> Dim cnn As New SqlClient.SqlConnection
>>> Dim cmd As New SqlClient.SqlCommand
>>> Dim rbl As RadioButtonList = Me.rblCannedRpts
>>> Dim sStr As String
>>>
>>> cnn.ConnectionString = gcsCnnStr
>>> cmd.CommandType = CommandType.StoredProcedure
>>> cmd.CommandText = "_sp_getCannedReports"
>>> cmd.Connection = cnn
>>>
>>> Try
>>>    cnn.Open()
>>>    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>    While rdr.Read
>>>        Dim itm As New ListItem(rdr.Item("cannedName"),
>>> rdr.Item("spnames"))
>>>        rbl.Items.Add(itm)
>>>    End While
>>>    rdr.Close()
>>>    cnn.Close()
>>> Catch ex As Exception
>>>    Stop
>>> End Try
>>>
>>> End Sub
>>>
>>> ==================================
>>> The code that looks for the selected button is here:
>>> ==================================
>>>
>>> Private Sub loadHashTable(ByVal acontainer As Object)
>>>    'loop thru all controls on page - stuff all checkboxes or radio
>>> button that are not null
>>>    'into hashtable
>>>
>>>    Dim ctrl As Control
>>>    For Each ctrl In acontainer.controls
>>>        If ctrl.HasControls Then
>>>            Call loadHashTable(ctrl)
>>>        End If
>>>        If TypeOf ctrl Is CheckBox Then
>>>            With ctrl
>>>                If CType(ctrl, CheckBox).Checked Then
>>>                    mHT.Add(ctrl.ID, ctrl.ID)
>>>                End If
>>>            End With
>>>        ElseIf TypeOf ctrl Is RadioButtonList Then
>>>            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>                 Stop <<< never get to this point...selectedIndex is
>>> always -1 !>>>
>>>            End If
>>>        End If
>>> Next
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
Author
10 Feb 2006 9:52 PM
astropup
here it is.........

Public Class fwc_spec
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

    End Sub
    Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
    Protected WithEvents chkFemaleWOChildrenMin As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkFemaleWOChildrenMax As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkMaleWOChildrenMin As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkMaleWOChildrenMax As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkFemaleWChildrenMin As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkFemaleWChildrenMax As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkMaleWChildrenMin As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkMaleWChildrenMax As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCoupleWOChildrenMin As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCoupleWOChildrenMax As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCouplewChildrenMin As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCouplewChildrenMax As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkRentMin As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkRentMax As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkMortgageMin As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkMortgageMax As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkHrsWorkedMin As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkHrsWorkedMax As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkEducationMin As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkEducationMax As
System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkIncomeMin As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkIncomeMax As System.Web.UI.WebControls.CheckBox
    Protected WithEvents btnGenGraph As System.Web.UI.WebControls.Button
    Protected WithEvents rblCannedRpts As
System.Web.UI.WebControls.RadioButtonList


    'NOTE: The following placeholder declaration is required by the Web Form
Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private mHT As New Hashtable

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        Call LoadrblCanRpts()

    End Sub

    Private Sub loadrblCanRpts()
        Dim cnn As New SqlClient.SqlConnection
        Dim cmd As New SqlClient.SqlCommand
        Dim rbl As RadioButtonList = Me.rblCannedRpts
        Dim sStr As String

        If Not Page.IsPostBack Then
            cnn.ConnectionString = gcsCnnStr
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = "_sp_getCannedReports"
            cmd.Connection = cnn

            Try
                cnn.Open()
                Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
                While rdr.Read
                    Dim itm As New ListItem(rdr.Item("cannedName"),
rdr.Item("spnames"))
                    rbl.Items.Add(itm)
                End While
                rdr.Close()
                cnn.Close()
            Catch ex As Exception
                Stop
            End Try
        End If

    End Sub

    Private Sub btnGenGraph_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnGenGraph.Click
        'dump selected attributes into hashtable
        Call loadHashTable(Page)
        'push hasttable into session variable so followpage can access it
        Session("checkSelection") = mHT
        'get out of dodge!
        Response.Redirect("fwc_graph.aspx")
    End Sub

    Private Sub loadHashTable(ByVal acontainer As Object)
        'loop thru all controls on page - stuff all checkboxes or radio
button that are not null
        'into hashtable
        Dim ctrl As Control

        For Each ctrl In acontainer.controls
            If ctrl.HasControls Then
                Call loadHashTable(ctrl)
            End If
            If TypeOf ctrl Is CheckBox Then
                With ctrl
                    If CType(ctrl, CheckBox).Checked Then
                        mHT.Add(ctrl.ID, ctrl.ID)
                    End If
                End With
            ElseIf TypeOf ctrl Is RadioButtonList Then
                If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
                    Stop
                End If
                Stop
            End If
        Next
    End Sub

End Class

======================================================================
HTML
======================================================================

<%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web"
Assembly="CrystalDecisions.Web, Version=9.1.5000.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304" %>
<%@ Page language="VB" AutoEventWireup="false" Codebehind="fwc_spec.aspx.vb"
Inherits="funWithCensus.fwc_spec" enableViewState="False"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <HEAD>
    <title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
<meta content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
<meta content=JavaScript name=vs_defaultClientScript>
<meta content=http://schemas.microsoft.com/intellisense/ie5
name=vs_targetSchema>
<SCRIPT language=javascript id=clientEventHandlersJS>
<!--

function chkPair(aObj)
{
if (aObj.checked == true)
  // uncheck its mate
  {getMatch(aObj).checked = false}
unCheckCanned()
}


function getMatch(objClicked){
//find match and return it
var prefix
var objRet

prefix = objClicked.id.substring(0, objClicked.id.length - 3)
switch (objClicked.id.substring(objClicked.id.length - 3,
objClicked.id.length).toLowerCase())
{
  case "min":
  objRet = document.getElementById(prefix + "Max")
  break
  case "max":
  objRet = document.getElementById(prefix + "Min")
  break
  default:
  }
  return objRet
}

function unCheckCustom()
{
//loop thru custom checkboxes...unchecking all of then
var e =  document.forms[0].elements
var cnt = e.length
for (var i=0; i<cnt; i++){
   if(e[i].type == "checkbox") {
    {e[i].checked = false}
    }
  }
}

function unCheckCanned()
{
//loop thru can'd option's - unchecking all of them
var e =  document.forms[0].elements
var cnt = e.length
for (var i=0; i<cnt; i++){
   if(e[i].type == "radio") {
    {e[i].checked = false}
    }
  }


}

//-->

</SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id=Form1 method=post runat="server"><asp:panel
id=Panel1 style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 24px"
runat="server" Width="664px" Height="864px">
<TABLE ID=Table1 STYLE="WIDTH: 528px; HEIGHT: 592px" CELLSPACING=1
CELLPADDING=1
WIDTH=528 BORDER=1>
  <TR>
    <TD STYLE="WIDTH: 293px; HEIGHT: 23px"><EM>Demographic Items of
      interest</EM></TD>
    <TD STYLE="WIDTH: 51px; HEIGHT: 23px; TEXT-ALIGN: center">Max
Density</TD>
    <TD STYLE="HEIGHT: 23px">
      <P STYLE="TEXT-ALIGN: center">Min Density</P></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Income</TD>
    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" VALIGN=middle
align=center><asp:CheckBox id=chkIncomeMax onclick="return
chkPair(document.getElementById('chkIncomeMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
rowSpan=1><asp:CheckBox id=chkIncomeMin onclick="return
chkPair(document.getElementById('chkIncomeMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Education</TD>
    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center"><asp:CheckBox
id=chkEducationMax onclick="return
chkPair(document.getElementById('chkEducationMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
rowSpan=1><asp:CheckBox id=chkEducationMin onclick="return
chkPair(document.getElementById('chkEducationMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Hours worked</TD>
    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center><asp:CheckBox
id=chkHrsWorkedMax onclick="return
chkPair(document.getElementById('chkHrsWorkedMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
rowSpan=1><asp:CheckBox id=chkHrsWorkedMin onclick="return
chkPair(document.getElementById('chkHrsWorkedMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Home owners</TD>
    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
rowSpan=1><asp:CheckBox id=chkMortgageMax onclick="return
chkPair(document.getElementById('chkMortgageMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
rowSpan=1><asp:CheckBox id=chkMortgageMin onclick="return
chkPair(document.getElementById('chkMortgageMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Renters</TD>
    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
rowSpan=1><asp:CheckBox id=chkRentMax onclick="return
chkPair(document.getElementById('chkRentMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
rowSpan=1><asp:CheckBox id=chkRentMin onclick="return
chkPair(document.getElementById('chkRentMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Couples with children</TD>
    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
rowSpan=1><asp:CheckBox id=chkCouplewChildrenMax onclick="return
chkPair(document.getElementById('chkCouplewChildrenMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
id=chkCouplewChildrenMin onclick="return
chkPair(document.getElementById('chkCouplewChildrenMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Couples w/o children</TD>
    <TD STYLE="WIDTH: 51px" align=center colSpan=1 rowSpan=1><asp:CheckBox
id=chkCoupleWOChildrenMax onclick="return
chkPair(document.getElementById('chkCoupleWOChildrenMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
id=chkCoupleWOChildrenMin onclick="return
chkPair(document.getElementById('chkCoupleWOChildrenMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Single male with children</TD>
    <TD STYLE="WIDTH: 51px" align=center><asp:CheckBox
id=chkMaleWChildrenMax onclick="return
chkPair(document.getElementById('chkMaleWChildrenMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD align=center><asp:CheckBox id=chkMaleWChildrenMin onclick="return
chkPair(document.getElementById('chkMaleWChildrenMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px; HEIGHT: 64px">Single female with children</TD>
    <TD STYLE="WIDTH: 51px; HEIGHT: 64px" align=center><asp:CheckBox
id=chkFemaleWChildrenMax onclick="return
chkPair(document.getElementById('chkFemaleWChildrenMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD STYLE="HEIGHT: 64px" align=center colSpan=1 rowSpan=1><asp:CheckBox
id=chkFemaleWChildrenMin onclick="return
chkPair(document.getElementById('chkFemaleWChildrenMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Single male w/o children</TD>
    <TD STYLE="WIDTH: 51px" align=center colSpan=1 rowSpan=1><asp:CheckBox
id=chkMaleWOChildrenMax runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
id=chkMaleWOChildrenMin onclick="return
chkPair(document.getElementById('chkMaleWOChildrenMin'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR>
  <TR>
    <TD STYLE="WIDTH: 293px">Single female w/o children</TD>
    <TD STYLE="WIDTH: 51px" align=center colSpan=1 rowSpan=1><asp:CheckBox
id=chkFemaleWOChildrenMax onclick="return
chkPair(document.getElementById('chkFemaleWOChildrenMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD>
    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
id=chkFemaleWOChildrenMin onclick="return
chkPair(document.getElementById('chkFemaleWOChildrenMax'))" runat="server"
EnableViewState="False"></asp:CheckBox></TD></TR></TABLE>
<DIV STYLE="WIDTH: 664px; POSITION: relative; HEIGHT: 241px"
MS_POSITIONING="GridLayout">
<DIV
STYLE="DISPLAY: inline; Z-INDEX: 101; LEFT: 16px; WIDTH: 472px; FONT-STYLE:
italic; POSITION: absolute; TOP: 16px; HEIGHT: 24px"
MS_POSITIONING="FlowLayout">Pre-built Reports</DIV>
<DIV
STYLE="Z-INDEX: 102; LEFT: 0px; WIDTH: 664px; POSITION: absolute; TOP: 48px;
HEIGHT: 172px"
MS_POSITIONING="FlowLayout"><asp:RadioButtonList id=rblCannedRpts
onclick="return unCheckCustom(this.form)" runat="server" Width="640px"
EnableViewState="False"></asp:RadioButtonList>
<HR WIDTH="100%" SIZE=1>

<DIV STYLE="WIDTH: 480px; POSITION: relative; HEIGHT: 112px"
MS_POSITIONING="GridLayout"><asp:button id=btnGenGraph style="Z-INDEX: 101;
LEFT: 152px; POSITION: absolute; TOP: 24px" runat="server" Height="64px"
Width="168px" Text="Generate
Graph"></asp:button></DIV></DIV></DIV></asp:panel></form>

  </body>
</HTML>

=============================================================================
=============================================================================

Show quoteHide quote
"Teemu Keiski" <jot***@aspalliance.com> wrote in message
news:O9AMBGoLGHA.3856@TK2MSFTNGP12.phx.gbl...
> So,
>
> how's the entire page's code like?
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
> "astropup" <astro***@mn.rr.com> wrote in message
> news:q56Hf.1233$xZ4.764@tornado.rdc-kc.rr.com...
>>
>> no - but I've added that and it makes no difference...
>>
>> -)
>>
>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>> news:e56%23EKmLGHA.208@tk2msftngp13.phx.gbl...
>>> Hi,
>>>
>>> does the initial populating happen inside If Not Page.IsPostback check?
>>> At which point do you check for the selection e.g in page_load,
>>> button_click etc?
>>>
>>> --
>>> Teemu Keiski
>>> ASP.NET MVP, AspInsider
>>> Finland, EU
>>> http://blogs.aspadvice.com/joteke
>>>
>>> "astropup" <astro***@mn.rr.com> wrote in message
>>> news:ts3Hf.551$CV.269@tornado.rdc-kc.rr.com...
>>>>
>>>> I'm trying to get the selected button in a radiobutton list....but the
>>>> selectedindex is always -1.    Any ideas what i'm doing wrong?
>>>> Thanks!
>>>>
>>>> ==================================
>>>> I've included the code that loads the radiobuttonList here:
>>>> ==================================
>>>> Private Sub loadrblCanRpts()
>>>>
>>>> Dim cnn As New SqlClient.SqlConnection
>>>> Dim cmd As New SqlClient.SqlCommand
>>>> Dim rbl As RadioButtonList = Me.rblCannedRpts
>>>> Dim sStr As String
>>>>
>>>> cnn.ConnectionString = gcsCnnStr
>>>> cmd.CommandType = CommandType.StoredProcedure
>>>> cmd.CommandText = "_sp_getCannedReports"
>>>> cmd.Connection = cnn
>>>>
>>>> Try
>>>>    cnn.Open()
>>>>    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>>    While rdr.Read
>>>>        Dim itm As New ListItem(rdr.Item("cannedName"),
>>>> rdr.Item("spnames"))
>>>>        rbl.Items.Add(itm)
>>>>    End While
>>>>    rdr.Close()
>>>>    cnn.Close()
>>>> Catch ex As Exception
>>>>    Stop
>>>> End Try
>>>>
>>>> End Sub
>>>>
>>>> ==================================
>>>> The code that looks for the selected button is here:
>>>> ==================================
>>>>
>>>> Private Sub loadHashTable(ByVal acontainer As Object)
>>>>    'loop thru all controls on page - stuff all checkboxes or radio
>>>> button that are not null
>>>>    'into hashtable
>>>>
>>>>    Dim ctrl As Control
>>>>    For Each ctrl In acontainer.controls
>>>>        If ctrl.HasControls Then
>>>>            Call loadHashTable(ctrl)
>>>>        End If
>>>>        If TypeOf ctrl Is CheckBox Then
>>>>            With ctrl
>>>>                If CType(ctrl, CheckBox).Checked Then
>>>>                    mHT.Add(ctrl.ID, ctrl.ID)
>>>>                End If
>>>>            End With
>>>>        ElseIf TypeOf ctrl Is RadioButtonList Then
>>>>            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>>                 Stop <<< never get to this point...selectedIndex is
>>>> always -1 !>>>
>>>>            End If
>>>>        End If
>>>> Next
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
11 Feb 2006 7:53 AM
Teemu Keiski
Try removing EnableViewState="False" from the RadioButtonList


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Show quoteHide quote
"astropup" <astro***@mn.rr.com> wrote in message
news:DW7Hf.1242$xZ4.712@tornado.rdc-kc.rr.com...
> here it is.........
>
> Public Class fwc_spec
>    Inherits System.Web.UI.Page
>
> #Region " Web Form Designer Generated Code "
>
>    'This call is required by the Web Form Designer.
>    <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
>
>    End Sub
>    Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
>    Protected WithEvents chkFemaleWOChildrenMin As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkFemaleWOChildrenMax As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkMaleWOChildrenMin As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkMaleWOChildrenMax As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkFemaleWChildrenMin As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkFemaleWChildrenMax As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkMaleWChildrenMin As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkMaleWChildrenMax As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkCoupleWOChildrenMin As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkCoupleWOChildrenMax As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkCouplewChildrenMin As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkCouplewChildrenMax As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkRentMin As System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkRentMax As System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkMortgageMin As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkMortgageMax As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkHrsWorkedMin As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkHrsWorkedMax As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkEducationMin As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkEducationMax As
> System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkIncomeMin As System.Web.UI.WebControls.CheckBox
>    Protected WithEvents chkIncomeMax As System.Web.UI.WebControls.CheckBox
>    Protected WithEvents btnGenGraph As System.Web.UI.WebControls.Button
>    Protected WithEvents rblCannedRpts As
> System.Web.UI.WebControls.RadioButtonList
>
>
>    'NOTE: The following placeholder declaration is required by the Web
> Form Designer.
>    'Do not delete or move it.
>    Private designerPlaceholderDeclaration As System.Object
>
>    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
>        'CODEGEN: This method call is required by the Web Form Designer
>        'Do not modify it using the code editor.
>        InitializeComponent()
>    End Sub
>
> #End Region
>
>    Private mHT As New Hashtable
>
>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>        Call LoadrblCanRpts()
>
>    End Sub
>
>    Private Sub loadrblCanRpts()
>        Dim cnn As New SqlClient.SqlConnection
>        Dim cmd As New SqlClient.SqlCommand
>        Dim rbl As RadioButtonList = Me.rblCannedRpts
>        Dim sStr As String
>
>        If Not Page.IsPostBack Then
>            cnn.ConnectionString = gcsCnnStr
>            cmd.CommandType = CommandType.StoredProcedure
>            cmd.CommandText = "_sp_getCannedReports"
>            cmd.Connection = cnn
>
>            Try
>                cnn.Open()
>                Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>                While rdr.Read
>                    Dim itm As New ListItem(rdr.Item("cannedName"),
> rdr.Item("spnames"))
>                    rbl.Items.Add(itm)
>                End While
>                rdr.Close()
>                cnn.Close()
>            Catch ex As Exception
>                Stop
>            End Try
>        End If
>
>    End Sub
>
>    Private Sub btnGenGraph_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnGenGraph.Click
>        'dump selected attributes into hashtable
>        Call loadHashTable(Page)
>        'push hasttable into session variable so followpage can access it
>        Session("checkSelection") = mHT
>        'get out of dodge!
>        Response.Redirect("fwc_graph.aspx")
>    End Sub
>
>    Private Sub loadHashTable(ByVal acontainer As Object)
>        'loop thru all controls on page - stuff all checkboxes or radio
> button that are not null
>        'into hashtable
>        Dim ctrl As Control
>
>        For Each ctrl In acontainer.controls
>            If ctrl.HasControls Then
>                Call loadHashTable(ctrl)
>            End If
>            If TypeOf ctrl Is CheckBox Then
>                With ctrl
>                    If CType(ctrl, CheckBox).Checked Then
>                        mHT.Add(ctrl.ID, ctrl.ID)
>                    End If
>                End With
>            ElseIf TypeOf ctrl Is RadioButtonList Then
>                If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>                    Stop
>                End If
>                Stop
>            End If
>        Next
>    End Sub
>
> End Class
>
> ======================================================================
> HTML
> ======================================================================
>
> <%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web"
> Assembly="CrystalDecisions.Web, Version=9.1.5000.0, Culture=neutral,
> PublicKeyToken=692fbea5521e1304" %>
> <%@ Page language="VB" AutoEventWireup="false"
> Codebehind="fwc_spec.aspx.vb" Inherits="funWithCensus.fwc_spec"
> enableViewState="False"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
>  <HEAD>
>    <title>WebForm1</title>
> <meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
> <meta content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
> <meta content=JavaScript name=vs_defaultClientScript>
> <meta content=http://schemas.microsoft.com/intellisense/ie5
> name=vs_targetSchema>
> <SCRIPT language=javascript id=clientEventHandlersJS>
> <!--
>
> function chkPair(aObj)
> {
> if (aObj.checked == true)
>  // uncheck its mate
>  {getMatch(aObj).checked = false}
> unCheckCanned()
> }
>
>
> function getMatch(objClicked){
> //find match and return it
> var prefix
> var objRet
>
> prefix = objClicked.id.substring(0, objClicked.id.length - 3)
> switch (objClicked.id.substring(objClicked.id.length - 3,
> objClicked.id.length).toLowerCase())
> {
>  case "min":
>  objRet = document.getElementById(prefix + "Max")
>  break
>  case "max":
>  objRet = document.getElementById(prefix + "Min")
>  break
>  default:
>  }
>  return objRet
> }
>
> function unCheckCustom()
> {
> //loop thru custom checkboxes...unchecking all of then
> var e =  document.forms[0].elements
> var cnt = e.length
> for (var i=0; i<cnt; i++){
>   if(e[i].type == "checkbox") {
>    {e[i].checked = false}
>    }
>  }
> }
>
> function unCheckCanned()
> {
> //loop thru can'd option's - unchecking all of them
> var e =  document.forms[0].elements
> var cnt = e.length
> for (var i=0; i<cnt; i++){
>   if(e[i].type == "radio") {
>    {e[i].checked = false}
>    }
>  }
>
>
> }
>
> //-->
>
> </SCRIPT>
> </HEAD>
> <body MS_POSITIONING="GridLayout">
> <form id=Form1 method=post runat="server"><asp:panel
> id=Panel1 style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 24px"
> runat="server" Width="664px" Height="864px">
> <TABLE ID=Table1 STYLE="WIDTH: 528px; HEIGHT: 592px" CELLSPACING=1
> CELLPADDING=1
> WIDTH=528 BORDER=1>
>  <TR>
>    <TD STYLE="WIDTH: 293px; HEIGHT: 23px"><EM>Demographic Items of
>      interest</EM></TD>
>    <TD STYLE="WIDTH: 51px; HEIGHT: 23px; TEXT-ALIGN: center">Max
> Density</TD>
>    <TD STYLE="HEIGHT: 23px">
>      <P STYLE="TEXT-ALIGN: center">Min Density</P></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Income</TD>
>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" VALIGN=middle
> align=center><asp:CheckBox id=chkIncomeMax onclick="return
> chkPair(document.getElementById('chkIncomeMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
> rowSpan=1><asp:CheckBox id=chkIncomeMin onclick="return
> chkPair(document.getElementById('chkIncomeMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Education</TD>
>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center"><asp:CheckBox
> id=chkEducationMax onclick="return
> chkPair(document.getElementById('chkEducationMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
> rowSpan=1><asp:CheckBox id=chkEducationMin onclick="return
> chkPair(document.getElementById('chkEducationMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Hours worked</TD>
>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center><asp:CheckBox
> id=chkHrsWorkedMax onclick="return
> chkPair(document.getElementById('chkHrsWorkedMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
> rowSpan=1><asp:CheckBox id=chkHrsWorkedMin onclick="return
> chkPair(document.getElementById('chkHrsWorkedMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Home owners</TD>
>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
> rowSpan=1><asp:CheckBox id=chkMortgageMax onclick="return
> chkPair(document.getElementById('chkMortgageMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
> rowSpan=1><asp:CheckBox id=chkMortgageMin onclick="return
> chkPair(document.getElementById('chkMortgageMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Renters</TD>
>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
> rowSpan=1><asp:CheckBox id=chkRentMax onclick="return
> chkPair(document.getElementById('chkRentMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
> rowSpan=1><asp:CheckBox id=chkRentMin onclick="return
> chkPair(document.getElementById('chkRentMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Couples with children</TD>
>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
> rowSpan=1><asp:CheckBox id=chkCouplewChildrenMax onclick="return
> chkPair(document.getElementById('chkCouplewChildrenMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
> id=chkCouplewChildrenMin onclick="return
> chkPair(document.getElementById('chkCouplewChildrenMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Couples w/o children</TD>
>    <TD STYLE="WIDTH: 51px" align=center colSpan=1 rowSpan=1><asp:CheckBox
> id=chkCoupleWOChildrenMax onclick="return
> chkPair(document.getElementById('chkCoupleWOChildrenMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
> id=chkCoupleWOChildrenMin onclick="return
> chkPair(document.getElementById('chkCoupleWOChildrenMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Single male with children</TD>
>    <TD STYLE="WIDTH: 51px" align=center><asp:CheckBox
> id=chkMaleWChildrenMax onclick="return
> chkPair(document.getElementById('chkMaleWChildrenMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD align=center><asp:CheckBox id=chkMaleWChildrenMin onclick="return
> chkPair(document.getElementById('chkMaleWChildrenMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px; HEIGHT: 64px">Single female with children</TD>
>    <TD STYLE="WIDTH: 51px; HEIGHT: 64px" align=center><asp:CheckBox
> id=chkFemaleWChildrenMax onclick="return
> chkPair(document.getElementById('chkFemaleWChildrenMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD STYLE="HEIGHT: 64px" align=center colSpan=1 rowSpan=1><asp:CheckBox
> id=chkFemaleWChildrenMin onclick="return
> chkPair(document.getElementById('chkFemaleWChildrenMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Single male w/o children</TD>
>    <TD STYLE="WIDTH: 51px" align=center colSpan=1 rowSpan=1><asp:CheckBox
> id=chkMaleWOChildrenMax runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
> id=chkMaleWOChildrenMin onclick="return
> chkPair(document.getElementById('chkMaleWOChildrenMin'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR>
>  <TR>
>    <TD STYLE="WIDTH: 293px">Single female w/o children</TD>
>    <TD STYLE="WIDTH: 51px" align=center colSpan=1 rowSpan=1><asp:CheckBox
> id=chkFemaleWOChildrenMax onclick="return
> chkPair(document.getElementById('chkFemaleWOChildrenMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD>
>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
> id=chkFemaleWOChildrenMin onclick="return
> chkPair(document.getElementById('chkFemaleWOChildrenMax'))" runat="server"
> EnableViewState="False"></asp:CheckBox></TD></TR></TABLE>
> <DIV STYLE="WIDTH: 664px; POSITION: relative; HEIGHT: 241px"
> MS_POSITIONING="GridLayout">
> <DIV
> STYLE="DISPLAY: inline; Z-INDEX: 101; LEFT: 16px; WIDTH: 472px;
> FONT-STYLE: italic; POSITION: absolute; TOP: 16px; HEIGHT: 24px"
> MS_POSITIONING="FlowLayout">Pre-built Reports</DIV>
> <DIV
> STYLE="Z-INDEX: 102; LEFT: 0px; WIDTH: 664px; POSITION: absolute; TOP:
> 48px; HEIGHT: 172px"
> MS_POSITIONING="FlowLayout"><asp:RadioButtonList id=rblCannedRpts
> onclick="return unCheckCustom(this.form)" runat="server" Width="640px"
> EnableViewState="False"></asp:RadioButtonList>
> <HR WIDTH="100%" SIZE=1>
>
> <DIV STYLE="WIDTH: 480px; POSITION: relative; HEIGHT: 112px"
> MS_POSITIONING="GridLayout"><asp:button id=btnGenGraph style="Z-INDEX:
> 101; LEFT: 152px; POSITION: absolute; TOP: 24px" runat="server"
> Height="64px" Width="168px" Text="Generate
> Graph"></asp:button></DIV></DIV></DIV></asp:panel></form>
>
>  </body>
> </HTML>
>
> =============================================================================
> =============================================================================
>
> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
> news:O9AMBGoLGHA.3856@TK2MSFTNGP12.phx.gbl...
>> So,
>>
>> how's the entire page's code like?
>>
>> --
>> Teemu Keiski
>> ASP.NET MVP, AspInsider
>> Finland, EU
>> http://blogs.aspadvice.com/joteke
>>
>> "astropup" <astro***@mn.rr.com> wrote in message
>> news:q56Hf.1233$xZ4.764@tornado.rdc-kc.rr.com...
>>>
>>> no - but I've added that and it makes no difference...
>>>
>>> -)
>>>
>>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>>> news:e56%23EKmLGHA.208@tk2msftngp13.phx.gbl...
>>>> Hi,
>>>>
>>>> does the initial populating happen inside If Not Page.IsPostback check?
>>>> At which point do you check for the selection e.g in page_load,
>>>> button_click etc?
>>>>
>>>> --
>>>> Teemu Keiski
>>>> ASP.NET MVP, AspInsider
>>>> Finland, EU
>>>> http://blogs.aspadvice.com/joteke
>>>>
>>>> "astropup" <astro***@mn.rr.com> wrote in message
>>>> news:ts3Hf.551$CV.269@tornado.rdc-kc.rr.com...
>>>>>
>>>>> I'm trying to get the selected button in a radiobutton list....but the
>>>>> selectedindex is always -1.    Any ideas what i'm doing wrong?
>>>>> Thanks!
>>>>>
>>>>> ==================================
>>>>> I've included the code that loads the radiobuttonList here:
>>>>> ==================================
>>>>> Private Sub loadrblCanRpts()
>>>>>
>>>>> Dim cnn As New SqlClient.SqlConnection
>>>>> Dim cmd As New SqlClient.SqlCommand
>>>>> Dim rbl As RadioButtonList = Me.rblCannedRpts
>>>>> Dim sStr As String
>>>>>
>>>>> cnn.ConnectionString = gcsCnnStr
>>>>> cmd.CommandType = CommandType.StoredProcedure
>>>>> cmd.CommandText = "_sp_getCannedReports"
>>>>> cmd.Connection = cnn
>>>>>
>>>>> Try
>>>>>    cnn.Open()
>>>>>    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>>>    While rdr.Read
>>>>>        Dim itm As New ListItem(rdr.Item("cannedName"),
>>>>> rdr.Item("spnames"))
>>>>>        rbl.Items.Add(itm)
>>>>>    End While
>>>>>    rdr.Close()
>>>>>    cnn.Close()
>>>>> Catch ex As Exception
>>>>>    Stop
>>>>> End Try
>>>>>
>>>>> End Sub
>>>>>
>>>>> ==================================
>>>>> The code that looks for the selected button is here:
>>>>> ==================================
>>>>>
>>>>> Private Sub loadHashTable(ByVal acontainer As Object)
>>>>>    'loop thru all controls on page - stuff all checkboxes or radio
>>>>> button that are not null
>>>>>    'into hashtable
>>>>>
>>>>>    Dim ctrl As Control
>>>>>    For Each ctrl In acontainer.controls
>>>>>        If ctrl.HasControls Then
>>>>>            Call loadHashTable(ctrl)
>>>>>        End If
>>>>>        If TypeOf ctrl Is CheckBox Then
>>>>>            With ctrl
>>>>>                If CType(ctrl, CheckBox).Checked Then
>>>>>                    mHT.Add(ctrl.ID, ctrl.ID)
>>>>>                End If
>>>>>            End With
>>>>>        ElseIf TypeOf ctrl Is RadioButtonList Then
>>>>>            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>>>                 Stop <<< never get to this point...selectedIndex is
>>>>> always -1 !>>>
>>>>>            End If
>>>>>        End If
>>>>> Next
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
11 Feb 2006 1:53 PM
astropup
Thanks for the return post Teemu - I forgot to mention that I've already
tried that (with no success)

-(


Show quoteHide quote
"Teemu Keiski" <jot***@aspalliance.com> wrote in message
news:eV8ZbBuLGHA.668@TK2MSFTNGP11.phx.gbl...
> Try removing EnableViewState="False" from the RadioButtonList
>
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
> "astropup" <astro***@mn.rr.com> wrote in message
> news:DW7Hf.1242$xZ4.712@tornado.rdc-kc.rr.com...
>> here it is.........
>>
>> Public Class fwc_spec
>>    Inherits System.Web.UI.Page
>>
>> #Region " Web Form Designer Generated Code "
>>
>>    'This call is required by the Web Form Designer.
>>    <System.Diagnostics.DebuggerStepThrough()> Private Sub
>> InitializeComponent()
>>
>>    End Sub
>>    Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
>>    Protected WithEvents chkFemaleWOChildrenMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkFemaleWOChildrenMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkMaleWOChildrenMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkMaleWOChildrenMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkFemaleWChildrenMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkFemaleWChildrenMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkMaleWChildrenMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkMaleWChildrenMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkCoupleWOChildrenMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkCoupleWOChildrenMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkCouplewChildrenMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkCouplewChildrenMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkRentMin As System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkRentMax As System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkMortgageMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkMortgageMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkHrsWorkedMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkHrsWorkedMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkEducationMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkEducationMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkIncomeMin As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents chkIncomeMax As
>> System.Web.UI.WebControls.CheckBox
>>    Protected WithEvents btnGenGraph As System.Web.UI.WebControls.Button
>>    Protected WithEvents rblCannedRpts As
>> System.Web.UI.WebControls.RadioButtonList
>>
>>
>>    'NOTE: The following placeholder declaration is required by the Web
>> Form Designer.
>>    'Do not delete or move it.
>>    Private designerPlaceholderDeclaration As System.Object
>>
>>    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MyBase.Init
>>        'CODEGEN: This method call is required by the Web Form Designer
>>        'Do not modify it using the code editor.
>>        InitializeComponent()
>>    End Sub
>>
>> #End Region
>>
>>    Private mHT As New Hashtable
>>
>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MyBase.Load
>>        Call LoadrblCanRpts()
>>
>>    End Sub
>>
>>    Private Sub loadrblCanRpts()
>>        Dim cnn As New SqlClient.SqlConnection
>>        Dim cmd As New SqlClient.SqlCommand
>>        Dim rbl As RadioButtonList = Me.rblCannedRpts
>>        Dim sStr As String
>>
>>        If Not Page.IsPostBack Then
>>            cnn.ConnectionString = gcsCnnStr
>>            cmd.CommandType = CommandType.StoredProcedure
>>            cmd.CommandText = "_sp_getCannedReports"
>>            cmd.Connection = cnn
>>
>>            Try
>>                cnn.Open()
>>                Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>                While rdr.Read
>>                    Dim itm As New ListItem(rdr.Item("cannedName"),
>> rdr.Item("spnames"))
>>                    rbl.Items.Add(itm)
>>                End While
>>                rdr.Close()
>>                cnn.Close()
>>            Catch ex As Exception
>>                Stop
>>            End Try
>>        End If
>>
>>    End Sub
>>
>>    Private Sub btnGenGraph_Click(ByVal sender As System.Object, ByVal e
>> As System.EventArgs) Handles btnGenGraph.Click
>>        'dump selected attributes into hashtable
>>        Call loadHashTable(Page)
>>        'push hasttable into session variable so followpage can access it
>>        Session("checkSelection") = mHT
>>        'get out of dodge!
>>        Response.Redirect("fwc_graph.aspx")
>>    End Sub
>>
>>    Private Sub loadHashTable(ByVal acontainer As Object)
>>        'loop thru all controls on page - stuff all checkboxes or radio
>> button that are not null
>>        'into hashtable
>>        Dim ctrl As Control
>>
>>        For Each ctrl In acontainer.controls
>>            If ctrl.HasControls Then
>>                Call loadHashTable(ctrl)
>>            End If
>>            If TypeOf ctrl Is CheckBox Then
>>                With ctrl
>>                    If CType(ctrl, CheckBox).Checked Then
>>                        mHT.Add(ctrl.ID, ctrl.ID)
>>                    End If
>>                End With
>>            ElseIf TypeOf ctrl Is RadioButtonList Then
>>                If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>                    Stop
>>                End If
>>                Stop
>>            End If
>>        Next
>>    End Sub
>>
>> End Class
>>
>> ======================================================================
>> HTML
>> ======================================================================
>>
>> <%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web"
>> Assembly="CrystalDecisions.Web, Version=9.1.5000.0, Culture=neutral,
>> PublicKeyToken=692fbea5521e1304" %>
>> <%@ Page language="VB" AutoEventWireup="false"
>> Codebehind="fwc_spec.aspx.vb" Inherits="funWithCensus.fwc_spec"
>> enableViewState="False"%>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>> <HTML>
>>  <HEAD>
>>    <title>WebForm1</title>
>> <meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
>> <meta content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
>> <meta content=JavaScript name=vs_defaultClientScript>
>> <meta content=http://schemas.microsoft.com/intellisense/ie5
>> name=vs_targetSchema>
>> <SCRIPT language=javascript id=clientEventHandlersJS>
>> <!--
>>
>> function chkPair(aObj)
>> {
>> if (aObj.checked == true)
>>  // uncheck its mate
>>  {getMatch(aObj).checked = false}
>> unCheckCanned()
>> }
>>
>>
>> function getMatch(objClicked){
>> //find match and return it
>> var prefix
>> var objRet
>>
>> prefix = objClicked.id.substring(0, objClicked.id.length - 3)
>> switch (objClicked.id.substring(objClicked.id.length - 3,
>> objClicked.id.length).toLowerCase())
>> {
>>  case "min":
>>  objRet = document.getElementById(prefix + "Max")
>>  break
>>  case "max":
>>  objRet = document.getElementById(prefix + "Min")
>>  break
>>  default:
>>  }
>>  return objRet
>> }
>>
>> function unCheckCustom()
>> {
>> //loop thru custom checkboxes...unchecking all of then
>> var e =  document.forms[0].elements
>> var cnt = e.length
>> for (var i=0; i<cnt; i++){
>>   if(e[i].type == "checkbox") {
>>    {e[i].checked = false}
>>    }
>>  }
>> }
>>
>> function unCheckCanned()
>> {
>> //loop thru can'd option's - unchecking all of them
>> var e =  document.forms[0].elements
>> var cnt = e.length
>> for (var i=0; i<cnt; i++){
>>   if(e[i].type == "radio") {
>>    {e[i].checked = false}
>>    }
>>  }
>>
>>
>> }
>>
>> //-->
>>
>> </SCRIPT>
>> </HEAD>
>> <body MS_POSITIONING="GridLayout">
>> <form id=Form1 method=post runat="server"><asp:panel
>> id=Panel1 style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 24px"
>> runat="server" Width="664px" Height="864px">
>> <TABLE ID=Table1 STYLE="WIDTH: 528px; HEIGHT: 592px" CELLSPACING=1
>> CELLPADDING=1
>> WIDTH=528 BORDER=1>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px; HEIGHT: 23px"><EM>Demographic Items of
>>      interest</EM></TD>
>>    <TD STYLE="WIDTH: 51px; HEIGHT: 23px; TEXT-ALIGN: center">Max
>> Density</TD>
>>    <TD STYLE="HEIGHT: 23px">
>>      <P STYLE="TEXT-ALIGN: center">Min Density</P></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Income</TD>
>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" VALIGN=middle
>> align=center><asp:CheckBox id=chkIncomeMax onclick="return
>> chkPair(document.getElementById('chkIncomeMax'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD>
>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>> rowSpan=1><asp:CheckBox id=chkIncomeMin onclick="return
>> chkPair(document.getElementById('chkIncomeMin'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Education</TD>
>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center"><asp:CheckBox
>> id=chkEducationMax onclick="return
>> chkPair(document.getElementById('chkEducationMax'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD>
>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>> rowSpan=1><asp:CheckBox id=chkEducationMin onclick="return
>> chkPair(document.getElementById('chkEducationMin'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Hours worked</TD>
>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center><asp:CheckBox
>> id=chkHrsWorkedMax onclick="return
>> chkPair(document.getElementById('chkHrsWorkedMax'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD>
>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>> rowSpan=1><asp:CheckBox id=chkHrsWorkedMin onclick="return
>> chkPair(document.getElementById('chkHrsWorkedMin'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Home owners</TD>
>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>> rowSpan=1><asp:CheckBox id=chkMortgageMax onclick="return
>> chkPair(document.getElementById('chkMortgageMax'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD>
>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>> rowSpan=1><asp:CheckBox id=chkMortgageMin onclick="return
>> chkPair(document.getElementById('chkMortgageMin'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Renters</TD>
>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>> rowSpan=1><asp:CheckBox id=chkRentMax onclick="return
>> chkPair(document.getElementById('chkRentMax'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD>
>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>> rowSpan=1><asp:CheckBox id=chkRentMin onclick="return
>> chkPair(document.getElementById('chkRentMin'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Couples with children</TD>
>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>> rowSpan=1><asp:CheckBox id=chkCouplewChildrenMax onclick="return
>> chkPair(document.getElementById('chkCouplewChildrenMax'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD>
>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>> id=chkCouplewChildrenMin onclick="return
>> chkPair(document.getElementById('chkCouplewChildrenMin'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Couples w/o children</TD>
>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1 rowSpan=1><asp:CheckBox
>> id=chkCoupleWOChildrenMax onclick="return
>> chkPair(document.getElementById('chkCoupleWOChildrenMax'))"
>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>> id=chkCoupleWOChildrenMin onclick="return
>> chkPair(document.getElementById('chkCoupleWOChildrenMin'))"
>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Single male with children</TD>
>>    <TD STYLE="WIDTH: 51px" align=center><asp:CheckBox
>> id=chkMaleWChildrenMax onclick="return
>> chkPair(document.getElementById('chkMaleWChildrenMax'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD>
>>    <TD align=center><asp:CheckBox id=chkMaleWChildrenMin onclick="return
>> chkPair(document.getElementById('chkMaleWChildrenMin'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px; HEIGHT: 64px">Single female with
>> children</TD>
>>    <TD STYLE="WIDTH: 51px; HEIGHT: 64px" align=center><asp:CheckBox
>> id=chkFemaleWChildrenMax onclick="return
>> chkPair(document.getElementById('chkFemaleWChildrenMax'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD>
>>    <TD STYLE="HEIGHT: 64px" align=center colSpan=1
>> rowSpan=1><asp:CheckBox id=chkFemaleWChildrenMin onclick="return
>> chkPair(document.getElementById('chkFemaleWChildrenMin'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Single male w/o children</TD>
>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1 rowSpan=1><asp:CheckBox
>> id=chkMaleWOChildrenMax runat="server"
>> EnableViewState="False"></asp:CheckBox></TD>
>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>> id=chkMaleWOChildrenMin onclick="return
>> chkPair(document.getElementById('chkMaleWOChildrenMin'))" runat="server"
>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>  <TR>
>>    <TD STYLE="WIDTH: 293px">Single female w/o children</TD>
>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1 rowSpan=1><asp:CheckBox
>> id=chkFemaleWOChildrenMax onclick="return
>> chkPair(document.getElementById('chkFemaleWOChildrenMax'))"
>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>> id=chkFemaleWOChildrenMin onclick="return
>> chkPair(document.getElementById('chkFemaleWOChildrenMax'))"
>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR></TABLE>
>> <DIV STYLE="WIDTH: 664px; POSITION: relative; HEIGHT: 241px"
>> MS_POSITIONING="GridLayout">
>> <DIV
>> STYLE="DISPLAY: inline; Z-INDEX: 101; LEFT: 16px; WIDTH: 472px;
>> FONT-STYLE: italic; POSITION: absolute; TOP: 16px; HEIGHT: 24px"
>> MS_POSITIONING="FlowLayout">Pre-built Reports</DIV>
>> <DIV
>> STYLE="Z-INDEX: 102; LEFT: 0px; WIDTH: 664px; POSITION: absolute; TOP:
>> 48px; HEIGHT: 172px"
>> MS_POSITIONING="FlowLayout"><asp:RadioButtonList id=rblCannedRpts
>> onclick="return unCheckCustom(this.form)" runat="server" Width="640px"
>> EnableViewState="False"></asp:RadioButtonList>
>> <HR WIDTH="100%" SIZE=1>
>>
>> <DIV STYLE="WIDTH: 480px; POSITION: relative; HEIGHT: 112px"
>> MS_POSITIONING="GridLayout"><asp:button id=btnGenGraph style="Z-INDEX:
>> 101; LEFT: 152px; POSITION: absolute; TOP: 24px" runat="server"
>> Height="64px" Width="168px" Text="Generate
>> Graph"></asp:button></DIV></DIV></DIV></asp:panel></form>
>>
>>  </body>
>> </HTML>
>>
>> =============================================================================
>> =============================================================================
>>
>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>> news:O9AMBGoLGHA.3856@TK2MSFTNGP12.phx.gbl...
>>> So,
>>>
>>> how's the entire page's code like?
>>>
>>> --
>>> Teemu Keiski
>>> ASP.NET MVP, AspInsider
>>> Finland, EU
>>> http://blogs.aspadvice.com/joteke
>>>
>>> "astropup" <astro***@mn.rr.com> wrote in message
>>> news:q56Hf.1233$xZ4.764@tornado.rdc-kc.rr.com...
>>>>
>>>> no - but I've added that and it makes no difference...
>>>>
>>>> -)
>>>>
>>>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>>>> news:e56%23EKmLGHA.208@tk2msftngp13.phx.gbl...
>>>>> Hi,
>>>>>
>>>>> does the initial populating happen inside If Not Page.IsPostback
>>>>> check? At which point do you check for the selection e.g in page_load,
>>>>> button_click etc?
>>>>>
>>>>> --
>>>>> Teemu Keiski
>>>>> ASP.NET MVP, AspInsider
>>>>> Finland, EU
>>>>> http://blogs.aspadvice.com/joteke
>>>>>
>>>>> "astropup" <astro***@mn.rr.com> wrote in message
>>>>> news:ts3Hf.551$CV.269@tornado.rdc-kc.rr.com...
>>>>>>
>>>>>> I'm trying to get the selected button in a radiobutton list....but
>>>>>> the selectedindex is always -1.    Any ideas what i'm doing wrong?
>>>>>> Thanks!
>>>>>>
>>>>>> ==================================
>>>>>> I've included the code that loads the radiobuttonList here:
>>>>>> ==================================
>>>>>> Private Sub loadrblCanRpts()
>>>>>>
>>>>>> Dim cnn As New SqlClient.SqlConnection
>>>>>> Dim cmd As New SqlClient.SqlCommand
>>>>>> Dim rbl As RadioButtonList = Me.rblCannedRpts
>>>>>> Dim sStr As String
>>>>>>
>>>>>> cnn.ConnectionString = gcsCnnStr
>>>>>> cmd.CommandType = CommandType.StoredProcedure
>>>>>> cmd.CommandText = "_sp_getCannedReports"
>>>>>> cmd.Connection = cnn
>>>>>>
>>>>>> Try
>>>>>>    cnn.Open()
>>>>>>    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>>>>    While rdr.Read
>>>>>>        Dim itm As New ListItem(rdr.Item("cannedName"),
>>>>>> rdr.Item("spnames"))
>>>>>>        rbl.Items.Add(itm)
>>>>>>    End While
>>>>>>    rdr.Close()
>>>>>>    cnn.Close()
>>>>>> Catch ex As Exception
>>>>>>    Stop
>>>>>> End Try
>>>>>>
>>>>>> End Sub
>>>>>>
>>>>>> ==================================
>>>>>> The code that looks for the selected button is here:
>>>>>> ==================================
>>>>>>
>>>>>> Private Sub loadHashTable(ByVal acontainer As Object)
>>>>>>    'loop thru all controls on page - stuff all checkboxes or radio
>>>>>> button that are not null
>>>>>>    'into hashtable
>>>>>>
>>>>>>    Dim ctrl As Control
>>>>>>    For Each ctrl In acontainer.controls
>>>>>>        If ctrl.HasControls Then
>>>>>>            Call loadHashTable(ctrl)
>>>>>>        End If
>>>>>>        If TypeOf ctrl Is CheckBox Then
>>>>>>            With ctrl
>>>>>>                If CType(ctrl, CheckBox).Checked Then
>>>>>>                    mHT.Add(ctrl.ID, ctrl.ID)
>>>>>>                End If
>>>>>>            End With
>>>>>>        ElseIf TypeOf ctrl Is RadioButtonList Then
>>>>>>            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>>>>                 Stop <<< never get to this point...selectedIndex is
>>>>>> always -1 !>>>
>>>>>>            End If
>>>>>>        End If
>>>>>> Next
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
11 Feb 2006 2:13 PM
Teemu Keiski
So basically, if you make a selection in the RadioButtonList, it is cleared
on postback? That should indicate if SelectedIndex always stays at -1.
Put all ViewStates back, also on Page level, and if it doesn't help, try to
cut down the code so that you can isolate the problematic part. E.g forget
the control iterating part and focus on that selection in RDB would be kept
over postback

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


Show quoteHide quote
"astropup" <astro***@mn.rr.com> wrote in message
news:1%lHf.655$CV.380@tornado.rdc-kc.rr.com...
> Thanks for the return post Teemu - I forgot to mention that I've already
> tried that (with no success)
>
> -(
>
>
> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
> news:eV8ZbBuLGHA.668@TK2MSFTNGP11.phx.gbl...
>> Try removing EnableViewState="False" from the RadioButtonList
>>
>>
>> --
>> Teemu Keiski
>> ASP.NET MVP, AspInsider
>> Finland, EU
>> http://blogs.aspadvice.com/joteke
>>
>> "astropup" <astro***@mn.rr.com> wrote in message
>> news:DW7Hf.1242$xZ4.712@tornado.rdc-kc.rr.com...
>>> here it is.........
>>>
>>> Public Class fwc_spec
>>>    Inherits System.Web.UI.Page
>>>
>>> #Region " Web Form Designer Generated Code "
>>>
>>>    'This call is required by the Web Form Designer.
>>>    <System.Diagnostics.DebuggerStepThrough()> Private Sub
>>> InitializeComponent()
>>>
>>>    End Sub
>>>    Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
>>>    Protected WithEvents chkFemaleWOChildrenMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkFemaleWOChildrenMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkMaleWOChildrenMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkMaleWOChildrenMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkFemaleWChildrenMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkFemaleWChildrenMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkMaleWChildrenMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkMaleWChildrenMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkCoupleWOChildrenMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkCoupleWOChildrenMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkCouplewChildrenMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkCouplewChildrenMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkRentMin As System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkRentMax As System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkMortgageMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkMortgageMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkHrsWorkedMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkHrsWorkedMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkEducationMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkEducationMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkIncomeMin As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents chkIncomeMax As
>>> System.Web.UI.WebControls.CheckBox
>>>    Protected WithEvents btnGenGraph As System.Web.UI.WebControls.Button
>>>    Protected WithEvents rblCannedRpts As
>>> System.Web.UI.WebControls.RadioButtonList
>>>
>>>
>>>    'NOTE: The following placeholder declaration is required by the Web
>>> Form Designer.
>>>    'Do not delete or move it.
>>>    Private designerPlaceholderDeclaration As System.Object
>>>
>>>    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles MyBase.Init
>>>        'CODEGEN: This method call is required by the Web Form Designer
>>>        'Do not modify it using the code editor.
>>>        InitializeComponent()
>>>    End Sub
>>>
>>> #End Region
>>>
>>>    Private mHT As New Hashtable
>>>
>>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles MyBase.Load
>>>        Call LoadrblCanRpts()
>>>
>>>    End Sub
>>>
>>>    Private Sub loadrblCanRpts()
>>>        Dim cnn As New SqlClient.SqlConnection
>>>        Dim cmd As New SqlClient.SqlCommand
>>>        Dim rbl As RadioButtonList = Me.rblCannedRpts
>>>        Dim sStr As String
>>>
>>>        If Not Page.IsPostBack Then
>>>            cnn.ConnectionString = gcsCnnStr
>>>            cmd.CommandType = CommandType.StoredProcedure
>>>            cmd.CommandText = "_sp_getCannedReports"
>>>            cmd.Connection = cnn
>>>
>>>            Try
>>>                cnn.Open()
>>>                Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>                While rdr.Read
>>>                    Dim itm As New ListItem(rdr.Item("cannedName"),
>>> rdr.Item("spnames"))
>>>                    rbl.Items.Add(itm)
>>>                End While
>>>                rdr.Close()
>>>                cnn.Close()
>>>            Catch ex As Exception
>>>                Stop
>>>            End Try
>>>        End If
>>>
>>>    End Sub
>>>
>>>    Private Sub btnGenGraph_Click(ByVal sender As System.Object, ByVal e
>>> As System.EventArgs) Handles btnGenGraph.Click
>>>        'dump selected attributes into hashtable
>>>        Call loadHashTable(Page)
>>>        'push hasttable into session variable so followpage can access it
>>>        Session("checkSelection") = mHT
>>>        'get out of dodge!
>>>        Response.Redirect("fwc_graph.aspx")
>>>    End Sub
>>>
>>>    Private Sub loadHashTable(ByVal acontainer As Object)
>>>        'loop thru all controls on page - stuff all checkboxes or radio
>>> button that are not null
>>>        'into hashtable
>>>        Dim ctrl As Control
>>>
>>>        For Each ctrl In acontainer.controls
>>>            If ctrl.HasControls Then
>>>                Call loadHashTable(ctrl)
>>>            End If
>>>            If TypeOf ctrl Is CheckBox Then
>>>                With ctrl
>>>                    If CType(ctrl, CheckBox).Checked Then
>>>                        mHT.Add(ctrl.ID, ctrl.ID)
>>>                    End If
>>>                End With
>>>            ElseIf TypeOf ctrl Is RadioButtonList Then
>>>                If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>                    Stop
>>>                End If
>>>                Stop
>>>            End If
>>>        Next
>>>    End Sub
>>>
>>> End Class
>>>
>>> ======================================================================
>>> HTML
>>> ======================================================================
>>>
>>> <%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web"
>>> Assembly="CrystalDecisions.Web, Version=9.1.5000.0, Culture=neutral,
>>> PublicKeyToken=692fbea5521e1304" %>
>>> <%@ Page language="VB" AutoEventWireup="false"
>>> Codebehind="fwc_spec.aspx.vb" Inherits="funWithCensus.fwc_spec"
>>> enableViewState="False"%>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>>> <HTML>
>>>  <HEAD>
>>>    <title>WebForm1</title>
>>> <meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
>>> <meta content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
>>> <meta content=JavaScript name=vs_defaultClientScript>
>>> <meta content=http://schemas.microsoft.com/intellisense/ie5
>>> name=vs_targetSchema>
>>> <SCRIPT language=javascript id=clientEventHandlersJS>
>>> <!--
>>>
>>> function chkPair(aObj)
>>> {
>>> if (aObj.checked == true)
>>>  // uncheck its mate
>>>  {getMatch(aObj).checked = false}
>>> unCheckCanned()
>>> }
>>>
>>>
>>> function getMatch(objClicked){
>>> //find match and return it
>>> var prefix
>>> var objRet
>>>
>>> prefix = objClicked.id.substring(0, objClicked.id.length - 3)
>>> switch (objClicked.id.substring(objClicked.id.length - 3,
>>> objClicked.id.length).toLowerCase())
>>> {
>>>  case "min":
>>>  objRet = document.getElementById(prefix + "Max")
>>>  break
>>>  case "max":
>>>  objRet = document.getElementById(prefix + "Min")
>>>  break
>>>  default:
>>>  }
>>>  return objRet
>>> }
>>>
>>> function unCheckCustom()
>>> {
>>> //loop thru custom checkboxes...unchecking all of then
>>> var e =  document.forms[0].elements
>>> var cnt = e.length
>>> for (var i=0; i<cnt; i++){
>>>   if(e[i].type == "checkbox") {
>>>    {e[i].checked = false}
>>>    }
>>>  }
>>> }
>>>
>>> function unCheckCanned()
>>> {
>>> //loop thru can'd option's - unchecking all of them
>>> var e =  document.forms[0].elements
>>> var cnt = e.length
>>> for (var i=0; i<cnt; i++){
>>>   if(e[i].type == "radio") {
>>>    {e[i].checked = false}
>>>    }
>>>  }
>>>
>>>
>>> }
>>>
>>> //-->
>>>
>>> </SCRIPT>
>>> </HEAD>
>>> <body MS_POSITIONING="GridLayout">
>>> <form id=Form1 method=post runat="server"><asp:panel
>>> id=Panel1 style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP:
>>> 24px" runat="server" Width="664px" Height="864px">
>>> <TABLE ID=Table1 STYLE="WIDTH: 528px; HEIGHT: 592px" CELLSPACING=1
>>> CELLPADDING=1
>>> WIDTH=528 BORDER=1>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px; HEIGHT: 23px"><EM>Demographic Items of
>>>      interest</EM></TD>
>>>    <TD STYLE="WIDTH: 51px; HEIGHT: 23px; TEXT-ALIGN: center">Max
>>> Density</TD>
>>>    <TD STYLE="HEIGHT: 23px">
>>>      <P STYLE="TEXT-ALIGN: center">Min Density</P></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Income</TD>
>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" VALIGN=middle
>>> align=center><asp:CheckBox id=chkIncomeMax onclick="return
>>> chkPair(document.getElementById('chkIncomeMax'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkIncomeMin onclick="return
>>> chkPair(document.getElementById('chkIncomeMin'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Education</TD>
>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center"><asp:CheckBox
>>> id=chkEducationMax onclick="return
>>> chkPair(document.getElementById('chkEducationMax'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkEducationMin onclick="return
>>> chkPair(document.getElementById('chkEducationMin'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Hours worked</TD>
>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center"
>>> align=center><asp:CheckBox id=chkHrsWorkedMax onclick="return
>>> chkPair(document.getElementById('chkHrsWorkedMax'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkHrsWorkedMin onclick="return
>>> chkPair(document.getElementById('chkHrsWorkedMin'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Home owners</TD>
>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkMortgageMax onclick="return
>>> chkPair(document.getElementById('chkMortgageMax'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkMortgageMin onclick="return
>>> chkPair(document.getElementById('chkMortgageMin'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Renters</TD>
>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkRentMax onclick="return
>>> chkPair(document.getElementById('chkRentMax'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkRentMin onclick="return
>>> chkPair(document.getElementById('chkRentMin'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Couples with children</TD>
>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkCouplewChildrenMax onclick="return
>>> chkPair(document.getElementById('chkCouplewChildrenMax'))"
>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>> id=chkCouplewChildrenMin onclick="return
>>> chkPair(document.getElementById('chkCouplewChildrenMin'))"
>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Couples w/o children</TD>
>>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkCoupleWOChildrenMax onclick="return
>>> chkPair(document.getElementById('chkCoupleWOChildrenMax'))"
>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>> id=chkCoupleWOChildrenMin onclick="return
>>> chkPair(document.getElementById('chkCoupleWOChildrenMin'))"
>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Single male with children</TD>
>>>    <TD STYLE="WIDTH: 51px" align=center><asp:CheckBox
>>> id=chkMaleWChildrenMax onclick="return
>>> chkPair(document.getElementById('chkMaleWChildrenMax'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD align=center><asp:CheckBox id=chkMaleWChildrenMin onclick="return
>>> chkPair(document.getElementById('chkMaleWChildrenMin'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px; HEIGHT: 64px">Single female with
>>> children</TD>
>>>    <TD STYLE="WIDTH: 51px; HEIGHT: 64px" align=center><asp:CheckBox
>>> id=chkFemaleWChildrenMax onclick="return
>>> chkPair(document.getElementById('chkFemaleWChildrenMax'))"
>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD STYLE="HEIGHT: 64px" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkFemaleWChildrenMin onclick="return
>>> chkPair(document.getElementById('chkFemaleWChildrenMin'))"
>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Single male w/o children</TD>
>>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkMaleWOChildrenMax runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>> id=chkMaleWOChildrenMin onclick="return
>>> chkPair(document.getElementById('chkMaleWOChildrenMin'))" runat="server"
>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>  <TR>
>>>    <TD STYLE="WIDTH: 293px">Single female w/o children</TD>
>>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1
>>> rowSpan=1><asp:CheckBox id=chkFemaleWOChildrenMax onclick="return
>>> chkPair(document.getElementById('chkFemaleWOChildrenMax'))"
>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>> id=chkFemaleWOChildrenMin onclick="return
>>> chkPair(document.getElementById('chkFemaleWOChildrenMax'))"
>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR></TABLE>
>>> <DIV STYLE="WIDTH: 664px; POSITION: relative; HEIGHT: 241px"
>>> MS_POSITIONING="GridLayout">
>>> <DIV
>>> STYLE="DISPLAY: inline; Z-INDEX: 101; LEFT: 16px; WIDTH: 472px;
>>> FONT-STYLE: italic; POSITION: absolute; TOP: 16px; HEIGHT: 24px"
>>> MS_POSITIONING="FlowLayout">Pre-built Reports</DIV>
>>> <DIV
>>> STYLE="Z-INDEX: 102; LEFT: 0px; WIDTH: 664px; POSITION: absolute; TOP:
>>> 48px; HEIGHT: 172px"
>>> MS_POSITIONING="FlowLayout"><asp:RadioButtonList id=rblCannedRpts
>>> onclick="return unCheckCustom(this.form)" runat="server" Width="640px"
>>> EnableViewState="False"></asp:RadioButtonList>
>>> <HR WIDTH="100%" SIZE=1>
>>>
>>> <DIV STYLE="WIDTH: 480px; POSITION: relative; HEIGHT: 112px"
>>> MS_POSITIONING="GridLayout"><asp:button id=btnGenGraph style="Z-INDEX:
>>> 101; LEFT: 152px; POSITION: absolute; TOP: 24px" runat="server"
>>> Height="64px" Width="168px" Text="Generate
>>> Graph"></asp:button></DIV></DIV></DIV></asp:panel></form>
>>>
>>>  </body>
>>> </HTML>
>>>
>>> =============================================================================
>>> =============================================================================
>>>
>>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>>> news:O9AMBGoLGHA.3856@TK2MSFTNGP12.phx.gbl...
>>>> So,
>>>>
>>>> how's the entire page's code like?
>>>>
>>>> --
>>>> Teemu Keiski
>>>> ASP.NET MVP, AspInsider
>>>> Finland, EU
>>>> http://blogs.aspadvice.com/joteke
>>>>
>>>> "astropup" <astro***@mn.rr.com> wrote in message
>>>> news:q56Hf.1233$xZ4.764@tornado.rdc-kc.rr.com...
>>>>>
>>>>> no - but I've added that and it makes no difference...
>>>>>
>>>>> -)
>>>>>
>>>>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>>>>> news:e56%23EKmLGHA.208@tk2msftngp13.phx.gbl...
>>>>>> Hi,
>>>>>>
>>>>>> does the initial populating happen inside If Not Page.IsPostback
>>>>>> check? At which point do you check for the selection e.g in
>>>>>> page_load, button_click etc?
>>>>>>
>>>>>> --
>>>>>> Teemu Keiski
>>>>>> ASP.NET MVP, AspInsider
>>>>>> Finland, EU
>>>>>> http://blogs.aspadvice.com/joteke
>>>>>>
>>>>>> "astropup" <astro***@mn.rr.com> wrote in message
>>>>>> news:ts3Hf.551$CV.269@tornado.rdc-kc.rr.com...
>>>>>>>
>>>>>>> I'm trying to get the selected button in a radiobutton list....but
>>>>>>> the selectedindex is always -1.    Any ideas what i'm doing wrong?
>>>>>>> Thanks!
>>>>>>>
>>>>>>> ==================================
>>>>>>> I've included the code that loads the radiobuttonList here:
>>>>>>> ==================================
>>>>>>> Private Sub loadrblCanRpts()
>>>>>>>
>>>>>>> Dim cnn As New SqlClient.SqlConnection
>>>>>>> Dim cmd As New SqlClient.SqlCommand
>>>>>>> Dim rbl As RadioButtonList = Me.rblCannedRpts
>>>>>>> Dim sStr As String
>>>>>>>
>>>>>>> cnn.ConnectionString = gcsCnnStr
>>>>>>> cmd.CommandType = CommandType.StoredProcedure
>>>>>>> cmd.CommandText = "_sp_getCannedReports"
>>>>>>> cmd.Connection = cnn
>>>>>>>
>>>>>>> Try
>>>>>>>    cnn.Open()
>>>>>>>    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>>>>>    While rdr.Read
>>>>>>>        Dim itm As New ListItem(rdr.Item("cannedName"),
>>>>>>> rdr.Item("spnames"))
>>>>>>>        rbl.Items.Add(itm)
>>>>>>>    End While
>>>>>>>    rdr.Close()
>>>>>>>    cnn.Close()
>>>>>>> Catch ex As Exception
>>>>>>>    Stop
>>>>>>> End Try
>>>>>>>
>>>>>>> End Sub
>>>>>>>
>>>>>>> ==================================
>>>>>>> The code that looks for the selected button is here:
>>>>>>> ==================================
>>>>>>>
>>>>>>> Private Sub loadHashTable(ByVal acontainer As Object)
>>>>>>>    'loop thru all controls on page - stuff all checkboxes or radio
>>>>>>> button that are not null
>>>>>>>    'into hashtable
>>>>>>>
>>>>>>>    Dim ctrl As Control
>>>>>>>    For Each ctrl In acontainer.controls
>>>>>>>        If ctrl.HasControls Then
>>>>>>>            Call loadHashTable(ctrl)
>>>>>>>        End If
>>>>>>>        If TypeOf ctrl Is CheckBox Then
>>>>>>>            With ctrl
>>>>>>>                If CType(ctrl, CheckBox).Checked Then
>>>>>>>                    mHT.Add(ctrl.ID, ctrl.ID)
>>>>>>>                End If
>>>>>>>            End With
>>>>>>>        ElseIf TypeOf ctrl Is RadioButtonList Then
>>>>>>>            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>>>>>                 Stop <<< never get to this point...selectedIndex is
>>>>>>> always -1 !>>>
>>>>>>>            End If
>>>>>>>        End If
>>>>>>> Next
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
11 Feb 2006 2:21 PM
astropup
it's not cleared when I look at the page in the browser...but the value of
selected index is -1 at the server ..

from command window....
? CType(ctrl, RadioButtonList).SelectedIndex
-1


Ok - I will follow your suggestions.  Thanks for the feedback ))




Show quoteHide quote
"Teemu Keiski" <jot***@aspalliance.com> wrote in message
news:u8CYiVxLGHA.344@TK2MSFTNGP11.phx.gbl...
> So basically, if you make a selection in the RadioButtonList, it is
> cleared on postback? That should indicate if SelectedIndex always stays
> at -1.
> Put all ViewStates back, also on Page level, and if it doesn't help, try
> to cut down the code so that you can isolate the problematic part. E.g
> forget the control iterating part and focus on that selection in RDB would
> be kept over postback
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
>
> "astropup" <astro***@mn.rr.com> wrote in message
> news:1%lHf.655$CV.380@tornado.rdc-kc.rr.com...
>> Thanks for the return post Teemu - I forgot to mention that I've already
>> tried that (with no success)
>>
>> -(
>>
>>
>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>> news:eV8ZbBuLGHA.668@TK2MSFTNGP11.phx.gbl...
>>> Try removing EnableViewState="False" from the RadioButtonList
>>>
>>>
>>> --
>>> Teemu Keiski
>>> ASP.NET MVP, AspInsider
>>> Finland, EU
>>> http://blogs.aspadvice.com/joteke
>>>
>>> "astropup" <astro***@mn.rr.com> wrote in message
>>> news:DW7Hf.1242$xZ4.712@tornado.rdc-kc.rr.com...
>>>> here it is.........
>>>>
>>>> Public Class fwc_spec
>>>>    Inherits System.Web.UI.Page
>>>>
>>>> #Region " Web Form Designer Generated Code "
>>>>
>>>>    'This call is required by the Web Form Designer.
>>>>    <System.Diagnostics.DebuggerStepThrough()> Private Sub
>>>> InitializeComponent()
>>>>
>>>>    End Sub
>>>>    Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
>>>>    Protected WithEvents chkFemaleWOChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkFemaleWOChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMaleWOChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMaleWOChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkFemaleWChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkFemaleWChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMaleWChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMaleWChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkCoupleWOChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkCoupleWOChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkCouplewChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkCouplewChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkRentMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkRentMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMortgageMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMortgageMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkHrsWorkedMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkHrsWorkedMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkEducationMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkEducationMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkIncomeMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkIncomeMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents btnGenGraph As System.Web.UI.WebControls.Button
>>>>    Protected WithEvents rblCannedRpts As
>>>> System.Web.UI.WebControls.RadioButtonList
>>>>
>>>>
>>>>    'NOTE: The following placeholder declaration is required by the Web
>>>> Form Designer.
>>>>    'Do not delete or move it.
>>>>    Private designerPlaceholderDeclaration As System.Object
>>>>
>>>>    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles MyBase.Init
>>>>        'CODEGEN: This method call is required by the Web Form Designer
>>>>        'Do not modify it using the code editor.
>>>>        InitializeComponent()
>>>>    End Sub
>>>>
>>>> #End Region
>>>>
>>>>    Private mHT As New Hashtable
>>>>
>>>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles MyBase.Load
>>>>        Call LoadrblCanRpts()
>>>>
>>>>    End Sub
>>>>
>>>>    Private Sub loadrblCanRpts()
>>>>        Dim cnn As New SqlClient.SqlConnection
>>>>        Dim cmd As New SqlClient.SqlCommand
>>>>        Dim rbl As RadioButtonList = Me.rblCannedRpts
>>>>        Dim sStr As String
>>>>
>>>>        If Not Page.IsPostBack Then
>>>>            cnn.ConnectionString = gcsCnnStr
>>>>            cmd.CommandType = CommandType.StoredProcedure
>>>>            cmd.CommandText = "_sp_getCannedReports"
>>>>            cmd.Connection = cnn
>>>>
>>>>            Try
>>>>                cnn.Open()
>>>>                Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>>                While rdr.Read
>>>>                    Dim itm As New ListItem(rdr.Item("cannedName"),
>>>> rdr.Item("spnames"))
>>>>                    rbl.Items.Add(itm)
>>>>                End While
>>>>                rdr.Close()
>>>>                cnn.Close()
>>>>            Catch ex As Exception
>>>>                Stop
>>>>            End Try
>>>>        End If
>>>>
>>>>    End Sub
>>>>
>>>>    Private Sub btnGenGraph_Click(ByVal sender As System.Object, ByVal e
>>>> As System.EventArgs) Handles btnGenGraph.Click
>>>>        'dump selected attributes into hashtable
>>>>        Call loadHashTable(Page)
>>>>        'push hasttable into session variable so followpage can access
>>>> it
>>>>        Session("checkSelection") = mHT
>>>>        'get out of dodge!
>>>>        Response.Redirect("fwc_graph.aspx")
>>>>    End Sub
>>>>
>>>>    Private Sub loadHashTable(ByVal acontainer As Object)
>>>>        'loop thru all controls on page - stuff all checkboxes or radio
>>>> button that are not null
>>>>        'into hashtable
>>>>        Dim ctrl As Control
>>>>
>>>>        For Each ctrl In acontainer.controls
>>>>            If ctrl.HasControls Then
>>>>                Call loadHashTable(ctrl)
>>>>            End If
>>>>            If TypeOf ctrl Is CheckBox Then
>>>>                With ctrl
>>>>                    If CType(ctrl, CheckBox).Checked Then
>>>>                        mHT.Add(ctrl.ID, ctrl.ID)
>>>>                    End If
>>>>                End With
>>>>            ElseIf TypeOf ctrl Is RadioButtonList Then
>>>>                If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>>                    Stop
>>>>                End If
>>>>                Stop
>>>>            End If
>>>>        Next
>>>>    End Sub
>>>>
>>>> End Class
>>>>
>>>> ======================================================================
>>>> HTML
>>>> ======================================================================
>>>>
>>>> <%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web"
>>>> Assembly="CrystalDecisions.Web, Version=9.1.5000.0, Culture=neutral,
>>>> PublicKeyToken=692fbea5521e1304" %>
>>>> <%@ Page language="VB" AutoEventWireup="false"
>>>> Codebehind="fwc_spec.aspx.vb" Inherits="funWithCensus.fwc_spec"
>>>> enableViewState="False"%>
>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>>>> <HTML>
>>>>  <HEAD>
>>>>    <title>WebForm1</title>
>>>> <meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
>>>> <meta content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
>>>> <meta content=JavaScript name=vs_defaultClientScript>
>>>> <meta content=http://schemas.microsoft.com/intellisense/ie5
>>>> name=vs_targetSchema>
>>>> <SCRIPT language=javascript id=clientEventHandlersJS>
>>>> <!--
>>>>
>>>> function chkPair(aObj)
>>>> {
>>>> if (aObj.checked == true)
>>>>  // uncheck its mate
>>>>  {getMatch(aObj).checked = false}
>>>> unCheckCanned()
>>>> }
>>>>
>>>>
>>>> function getMatch(objClicked){
>>>> //find match and return it
>>>> var prefix
>>>> var objRet
>>>>
>>>> prefix = objClicked.id.substring(0, objClicked.id.length - 3)
>>>> switch (objClicked.id.substring(objClicked.id.length - 3,
>>>> objClicked.id.length).toLowerCase())
>>>> {
>>>>  case "min":
>>>>  objRet = document.getElementById(prefix + "Max")
>>>>  break
>>>>  case "max":
>>>>  objRet = document.getElementById(prefix + "Min")
>>>>  break
>>>>  default:
>>>>  }
>>>>  return objRet
>>>> }
>>>>
>>>> function unCheckCustom()
>>>> {
>>>> //loop thru custom checkboxes...unchecking all of then
>>>> var e =  document.forms[0].elements
>>>> var cnt = e.length
>>>> for (var i=0; i<cnt; i++){
>>>>   if(e[i].type == "checkbox") {
>>>>    {e[i].checked = false}
>>>>    }
>>>>  }
>>>> }
>>>>
>>>> function unCheckCanned()
>>>> {
>>>> //loop thru can'd option's - unchecking all of them
>>>> var e =  document.forms[0].elements
>>>> var cnt = e.length
>>>> for (var i=0; i<cnt; i++){
>>>>   if(e[i].type == "radio") {
>>>>    {e[i].checked = false}
>>>>    }
>>>>  }
>>>>
>>>>
>>>> }
>>>>
>>>> //-->
>>>>
>>>> </SCRIPT>
>>>> </HEAD>
>>>> <body MS_POSITIONING="GridLayout">
>>>> <form id=Form1 method=post runat="server"><asp:panel
>>>> id=Panel1 style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP:
>>>> 24px" runat="server" Width="664px" Height="864px">
>>>> <TABLE ID=Table1 STYLE="WIDTH: 528px; HEIGHT: 592px" CELLSPACING=1
>>>> CELLPADDING=1
>>>> WIDTH=528 BORDER=1>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px; HEIGHT: 23px"><EM>Demographic Items of
>>>>      interest</EM></TD>
>>>>    <TD STYLE="WIDTH: 51px; HEIGHT: 23px; TEXT-ALIGN: center">Max
>>>> Density</TD>
>>>>    <TD STYLE="HEIGHT: 23px">
>>>>      <P STYLE="TEXT-ALIGN: center">Min Density</P></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Income</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" VALIGN=middle
>>>> align=center><asp:CheckBox id=chkIncomeMax onclick="return
>>>> chkPair(document.getElementById('chkIncomeMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkIncomeMin onclick="return
>>>> chkPair(document.getElementById('chkIncomeMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Education</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center"><asp:CheckBox
>>>> id=chkEducationMax onclick="return
>>>> chkPair(document.getElementById('chkEducationMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkEducationMin onclick="return
>>>> chkPair(document.getElementById('chkEducationMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Hours worked</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center"
>>>> align=center><asp:CheckBox id=chkHrsWorkedMax onclick="return
>>>> chkPair(document.getElementById('chkHrsWorkedMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkHrsWorkedMin onclick="return
>>>> chkPair(document.getElementById('chkHrsWorkedMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Home owners</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkMortgageMax onclick="return
>>>> chkPair(document.getElementById('chkMortgageMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkMortgageMin onclick="return
>>>> chkPair(document.getElementById('chkMortgageMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Renters</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkRentMax onclick="return
>>>> chkPair(document.getElementById('chkRentMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkRentMin onclick="return
>>>> chkPair(document.getElementById('chkRentMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Couples with children</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkCouplewChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkCouplewChildrenMax'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>>> id=chkCouplewChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkCouplewChildrenMin'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Couples w/o children</TD>
>>>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkCoupleWOChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkCoupleWOChildrenMax'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>>> id=chkCoupleWOChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkCoupleWOChildrenMin'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Single male with children</TD>
>>>>    <TD STYLE="WIDTH: 51px" align=center><asp:CheckBox
>>>> id=chkMaleWChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkMaleWChildrenMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center><asp:CheckBox id=chkMaleWChildrenMin
>>>> onclick="return
>>>> chkPair(document.getElementById('chkMaleWChildrenMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px; HEIGHT: 64px">Single female with
>>>> children</TD>
>>>>    <TD STYLE="WIDTH: 51px; HEIGHT: 64px" align=center><asp:CheckBox
>>>> id=chkFemaleWChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkFemaleWChildrenMax'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="HEIGHT: 64px" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkFemaleWChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkFemaleWChildrenMin'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Single male w/o children</TD>
>>>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkMaleWOChildrenMax runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>>> id=chkMaleWOChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkMaleWOChildrenMin'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Single female w/o children</TD>
>>>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkFemaleWOChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkFemaleWOChildrenMax'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>>> id=chkFemaleWOChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkFemaleWOChildrenMax'))"
>>>> runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR></TABLE>
>>>> <DIV STYLE="WIDTH: 664px; POSITION: relative; HEIGHT: 241px"
>>>> MS_POSITIONING="GridLayout">
>>>> <DIV
>>>> STYLE="DISPLAY: inline; Z-INDEX: 101; LEFT: 16px; WIDTH: 472px;
>>>> FONT-STYLE: italic; POSITION: absolute; TOP: 16px; HEIGHT: 24px"
>>>> MS_POSITIONING="FlowLayout">Pre-built Reports</DIV>
>>>> <DIV
>>>> STYLE="Z-INDEX: 102; LEFT: 0px; WIDTH: 664px; POSITION: absolute; TOP:
>>>> 48px; HEIGHT: 172px"
>>>> MS_POSITIONING="FlowLayout"><asp:RadioButtonList id=rblCannedRpts
>>>> onclick="return unCheckCustom(this.form)" runat="server" Width="640px"
>>>> EnableViewState="False"></asp:RadioButtonList>
>>>> <HR WIDTH="100%" SIZE=1>
>>>>
>>>> <DIV STYLE="WIDTH: 480px; POSITION: relative; HEIGHT: 112px"
>>>> MS_POSITIONING="GridLayout"><asp:button id=btnGenGraph style="Z-INDEX:
>>>> 101; LEFT: 152px; POSITION: absolute; TOP: 24px" runat="server"
>>>> Height="64px" Width="168px" Text="Generate
>>>> Graph"></asp:button></DIV></DIV></DIV></asp:panel></form>
>>>>
>>>>  </body>
>>>> </HTML>
>>>>
>>>> =============================================================================
>>>> =============================================================================
>>>>
>>>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>>>> news:O9AMBGoLGHA.3856@TK2MSFTNGP12.phx.gbl...
>>>>> So,
>>>>>
>>>>> how's the entire page's code like?
>>>>>
>>>>> --
>>>>> Teemu Keiski
>>>>> ASP.NET MVP, AspInsider
>>>>> Finland, EU
>>>>> http://blogs.aspadvice.com/joteke
>>>>>
>>>>> "astropup" <astro***@mn.rr.com> wrote in message
>>>>> news:q56Hf.1233$xZ4.764@tornado.rdc-kc.rr.com...
>>>>>>
>>>>>> no - but I've added that and it makes no difference...
>>>>>>
>>>>>> -)
>>>>>>
>>>>>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>>>>>> news:e56%23EKmLGHA.208@tk2msftngp13.phx.gbl...
>>>>>>> Hi,
>>>>>>>
>>>>>>> does the initial populating happen inside If Not Page.IsPostback
>>>>>>> check? At which point do you check for the selection e.g in
>>>>>>> page_load, button_click etc?
>>>>>>>
>>>>>>> --
>>>>>>> Teemu Keiski
>>>>>>> ASP.NET MVP, AspInsider
>>>>>>> Finland, EU
>>>>>>> http://blogs.aspadvice.com/joteke
>>>>>>>
>>>>>>> "astropup" <astro***@mn.rr.com> wrote in message
>>>>>>> news:ts3Hf.551$CV.269@tornado.rdc-kc.rr.com...
>>>>>>>>
>>>>>>>> I'm trying to get the selected button in a radiobutton list....but
>>>>>>>> the selectedindex is always -1.    Any ideas what i'm doing wrong?
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>> ==================================
>>>>>>>> I've included the code that loads the radiobuttonList here:
>>>>>>>> ==================================
>>>>>>>> Private Sub loadrblCanRpts()
>>>>>>>>
>>>>>>>> Dim cnn As New SqlClient.SqlConnection
>>>>>>>> Dim cmd As New SqlClient.SqlCommand
>>>>>>>> Dim rbl As RadioButtonList = Me.rblCannedRpts
>>>>>>>> Dim sStr As String
>>>>>>>>
>>>>>>>> cnn.ConnectionString = gcsCnnStr
>>>>>>>> cmd.CommandType = CommandType.StoredProcedure
>>>>>>>> cmd.CommandText = "_sp_getCannedReports"
>>>>>>>> cmd.Connection = cnn
>>>>>>>>
>>>>>>>> Try
>>>>>>>>    cnn.Open()
>>>>>>>>    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>>>>>>    While rdr.Read
>>>>>>>>        Dim itm As New ListItem(rdr.Item("cannedName"),
>>>>>>>> rdr.Item("spnames"))
>>>>>>>>        rbl.Items.Add(itm)
>>>>>>>>    End While
>>>>>>>>    rdr.Close()
>>>>>>>>    cnn.Close()
>>>>>>>> Catch ex As Exception
>>>>>>>>    Stop
>>>>>>>> End Try
>>>>>>>>
>>>>>>>> End Sub
>>>>>>>>
>>>>>>>> ==================================
>>>>>>>> The code that looks for the selected button is here:
>>>>>>>> ==================================
>>>>>>>>
>>>>>>>> Private Sub loadHashTable(ByVal acontainer As Object)
>>>>>>>>    'loop thru all controls on page - stuff all checkboxes or radio
>>>>>>>> button that are not null
>>>>>>>>    'into hashtable
>>>>>>>>
>>>>>>>>    Dim ctrl As Control
>>>>>>>>    For Each ctrl In acontainer.controls
>>>>>>>>        If ctrl.HasControls Then
>>>>>>>>            Call loadHashTable(ctrl)
>>>>>>>>        End If
>>>>>>>>        If TypeOf ctrl Is CheckBox Then
>>>>>>>>            With ctrl
>>>>>>>>                If CType(ctrl, CheckBox).Checked Then
>>>>>>>>                    mHT.Add(ctrl.ID, ctrl.ID)
>>>>>>>>                End If
>>>>>>>>            End With
>>>>>>>>        ElseIf TypeOf ctrl Is RadioButtonList Then
>>>>>>>>            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>>>>>>                 Stop <<< never get to this point...selectedIndex is
>>>>>>>> always -1 !>>>
>>>>>>>>            End If
>>>>>>>>        End If
>>>>>>>> Next
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
13 Feb 2006 10:55 PM
astropup
ok - my faux pas

did not have the page enableviewstate set to 'True'

-)

Show quoteHide quote
"Teemu Keiski" <jot***@aspalliance.com> wrote in message
news:u8CYiVxLGHA.344@TK2MSFTNGP11.phx.gbl...
> So basically, if you make a selection in the RadioButtonList, it is
> cleared on postback? That should indicate if SelectedIndex always stays
> at -1.
> Put all ViewStates back, also on Page level, and if it doesn't help, try
> to cut down the code so that you can isolate the problematic part. E.g
> forget the control iterating part and focus on that selection in RDB would
> be kept over postback
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
>
> "astropup" <astro***@mn.rr.com> wrote in message
> news:1%lHf.655$CV.380@tornado.rdc-kc.rr.com...
>> Thanks for the return post Teemu - I forgot to mention that I've already
>> tried that (with no success)
>>
>> -(
>>
>>
>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>> news:eV8ZbBuLGHA.668@TK2MSFTNGP11.phx.gbl...
>>> Try removing EnableViewState="False" from the RadioButtonList
>>>
>>>
>>> --
>>> Teemu Keiski
>>> ASP.NET MVP, AspInsider
>>> Finland, EU
>>> http://blogs.aspadvice.com/joteke
>>>
>>> "astropup" <astro***@mn.rr.com> wrote in message
>>> news:DW7Hf.1242$xZ4.712@tornado.rdc-kc.rr.com...
>>>> here it is.........
>>>>
>>>> Public Class fwc_spec
>>>>    Inherits System.Web.UI.Page
>>>>
>>>> #Region " Web Form Designer Generated Code "
>>>>
>>>>    'This call is required by the Web Form Designer.
>>>>    <System.Diagnostics.DebuggerStepThrough()> Private Sub
>>>> InitializeComponent()
>>>>
>>>>    End Sub
>>>>    Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
>>>>    Protected WithEvents chkFemaleWOChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkFemaleWOChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMaleWOChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMaleWOChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkFemaleWChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkFemaleWChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMaleWChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMaleWChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkCoupleWOChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkCoupleWOChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkCouplewChildrenMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkCouplewChildrenMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkRentMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkRentMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMortgageMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkMortgageMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkHrsWorkedMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkHrsWorkedMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkEducationMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkEducationMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkIncomeMin As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents chkIncomeMax As
>>>> System.Web.UI.WebControls.CheckBox
>>>>    Protected WithEvents btnGenGraph As System.Web.UI.WebControls.Button
>>>>    Protected WithEvents rblCannedRpts As
>>>> System.Web.UI.WebControls.RadioButtonList
>>>>
>>>>
>>>>    'NOTE: The following placeholder declaration is required by the Web
>>>> Form Designer.
>>>>    'Do not delete or move it.
>>>>    Private designerPlaceholderDeclaration As System.Object
>>>>
>>>>    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles MyBase.Init
>>>>        'CODEGEN: This method call is required by the Web Form Designer
>>>>        'Do not modify it using the code editor.
>>>>        InitializeComponent()
>>>>    End Sub
>>>>
>>>> #End Region
>>>>
>>>>    Private mHT As New Hashtable
>>>>
>>>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles MyBase.Load
>>>>        Call LoadrblCanRpts()
>>>>
>>>>    End Sub
>>>>
>>>>    Private Sub loadrblCanRpts()
>>>>        Dim cnn As New SqlClient.SqlConnection
>>>>        Dim cmd As New SqlClient.SqlCommand
>>>>        Dim rbl As RadioButtonList = Me.rblCannedRpts
>>>>        Dim sStr As String
>>>>
>>>>        If Not Page.IsPostBack Then
>>>>            cnn.ConnectionString = gcsCnnStr
>>>>            cmd.CommandType = CommandType.StoredProcedure
>>>>            cmd.CommandText = "_sp_getCannedReports"
>>>>            cmd.Connection = cnn
>>>>
>>>>            Try
>>>>                cnn.Open()
>>>>                Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>>                While rdr.Read
>>>>                    Dim itm As New ListItem(rdr.Item("cannedName"),
>>>> rdr.Item("spnames"))
>>>>                    rbl.Items.Add(itm)
>>>>                End While
>>>>                rdr.Close()
>>>>                cnn.Close()
>>>>            Catch ex As Exception
>>>>                Stop
>>>>            End Try
>>>>        End If
>>>>
>>>>    End Sub
>>>>
>>>>    Private Sub btnGenGraph_Click(ByVal sender As System.Object, ByVal e
>>>> As System.EventArgs) Handles btnGenGraph.Click
>>>>        'dump selected attributes into hashtable
>>>>        Call loadHashTable(Page)
>>>>        'push hasttable into session variable so followpage can access
>>>> it
>>>>        Session("checkSelection") = mHT
>>>>        'get out of dodge!
>>>>        Response.Redirect("fwc_graph.aspx")
>>>>    End Sub
>>>>
>>>>    Private Sub loadHashTable(ByVal acontainer As Object)
>>>>        'loop thru all controls on page - stuff all checkboxes or radio
>>>> button that are not null
>>>>        'into hashtable
>>>>        Dim ctrl As Control
>>>>
>>>>        For Each ctrl In acontainer.controls
>>>>            If ctrl.HasControls Then
>>>>                Call loadHashTable(ctrl)
>>>>            End If
>>>>            If TypeOf ctrl Is CheckBox Then
>>>>                With ctrl
>>>>                    If CType(ctrl, CheckBox).Checked Then
>>>>                        mHT.Add(ctrl.ID, ctrl.ID)
>>>>                    End If
>>>>                End With
>>>>            ElseIf TypeOf ctrl Is RadioButtonList Then
>>>>                If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>>                    Stop
>>>>                End If
>>>>                Stop
>>>>            End If
>>>>        Next
>>>>    End Sub
>>>>
>>>> End Class
>>>>
>>>> ======================================================================
>>>> HTML
>>>> ======================================================================
>>>>
>>>> <%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web"
>>>> Assembly="CrystalDecisions.Web, Version=9.1.5000.0, Culture=neutral,
>>>> PublicKeyToken=692fbea5521e1304" %>
>>>> <%@ Page language="VB" AutoEventWireup="false"
>>>> Codebehind="fwc_spec.aspx.vb" Inherits="funWithCensus.fwc_spec"
>>>> enableViewState="False"%>
>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>>>> <HTML>
>>>>  <HEAD>
>>>>    <title>WebForm1</title>
>>>> <meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
>>>> <meta content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
>>>> <meta content=JavaScript name=vs_defaultClientScript>
>>>> <meta content=http://schemas.microsoft.com/intellisense/ie5
>>>> name=vs_targetSchema>
>>>> <SCRIPT language=javascript id=clientEventHandlersJS>
>>>> <!--
>>>>
>>>> function chkPair(aObj)
>>>> {
>>>> if (aObj.checked == true)
>>>>  // uncheck its mate
>>>>  {getMatch(aObj).checked = false}
>>>> unCheckCanned()
>>>> }
>>>>
>>>>
>>>> function getMatch(objClicked){
>>>> //find match and return it
>>>> var prefix
>>>> var objRet
>>>>
>>>> prefix = objClicked.id.substring(0, objClicked.id.length - 3)
>>>> switch (objClicked.id.substring(objClicked.id.length - 3,
>>>> objClicked.id.length).toLowerCase())
>>>> {
>>>>  case "min":
>>>>  objRet = document.getElementById(prefix + "Max")
>>>>  break
>>>>  case "max":
>>>>  objRet = document.getElementById(prefix + "Min")
>>>>  break
>>>>  default:
>>>>  }
>>>>  return objRet
>>>> }
>>>>
>>>> function unCheckCustom()
>>>> {
>>>> //loop thru custom checkboxes...unchecking all of then
>>>> var e =  document.forms[0].elements
>>>> var cnt = e.length
>>>> for (var i=0; i<cnt; i++){
>>>>   if(e[i].type == "checkbox") {
>>>>    {e[i].checked = false}
>>>>    }
>>>>  }
>>>> }
>>>>
>>>> function unCheckCanned()
>>>> {
>>>> //loop thru can'd option's - unchecking all of them
>>>> var e =  document.forms[0].elements
>>>> var cnt = e.length
>>>> for (var i=0; i<cnt; i++){
>>>>   if(e[i].type == "radio") {
>>>>    {e[i].checked = false}
>>>>    }
>>>>  }
>>>>
>>>>
>>>> }
>>>>
>>>> //-->
>>>>
>>>> </SCRIPT>
>>>> </HEAD>
>>>> <body MS_POSITIONING="GridLayout">
>>>> <form id=Form1 method=post runat="server"><asp:panel
>>>> id=Panel1 style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP:
>>>> 24px" runat="server" Width="664px" Height="864px">
>>>> <TABLE ID=Table1 STYLE="WIDTH: 528px; HEIGHT: 592px" CELLSPACING=1
>>>> CELLPADDING=1
>>>> WIDTH=528 BORDER=1>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px; HEIGHT: 23px"><EM>Demographic Items of
>>>>      interest</EM></TD>
>>>>    <TD STYLE="WIDTH: 51px; HEIGHT: 23px; TEXT-ALIGN: center">Max
>>>> Density</TD>
>>>>    <TD STYLE="HEIGHT: 23px">
>>>>      <P STYLE="TEXT-ALIGN: center">Min Density</P></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Income</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" VALIGN=middle
>>>> align=center><asp:CheckBox id=chkIncomeMax onclick="return
>>>> chkPair(document.getElementById('chkIncomeMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkIncomeMin onclick="return
>>>> chkPair(document.getElementById('chkIncomeMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Education</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center"><asp:CheckBox
>>>> id=chkEducationMax onclick="return
>>>> chkPair(document.getElementById('chkEducationMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkEducationMin onclick="return
>>>> chkPair(document.getElementById('chkEducationMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Hours worked</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center"
>>>> align=center><asp:CheckBox id=chkHrsWorkedMax onclick="return
>>>> chkPair(document.getElementById('chkHrsWorkedMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkHrsWorkedMin onclick="return
>>>> chkPair(document.getElementById('chkHrsWorkedMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Home owners</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkMortgageMax onclick="return
>>>> chkPair(document.getElementById('chkMortgageMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkMortgageMin onclick="return
>>>> chkPair(document.getElementById('chkMortgageMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Renters</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkRentMax onclick="return
>>>> chkPair(document.getElementById('chkRentMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkRentMin onclick="return
>>>> chkPair(document.getElementById('chkRentMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Couples with children</TD>
>>>>    <TD STYLE="WIDTH: 51px; TEXT-ALIGN: center" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkCouplewChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkCouplewChildrenMax'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>>> id=chkCouplewChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkCouplewChildrenMin'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Couples w/o children</TD>
>>>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkCoupleWOChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkCoupleWOChildrenMax'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>>> id=chkCoupleWOChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkCoupleWOChildrenMin'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Single male with children</TD>
>>>>    <TD STYLE="WIDTH: 51px" align=center><asp:CheckBox
>>>> id=chkMaleWChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkMaleWChildrenMax'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center><asp:CheckBox id=chkMaleWChildrenMin
>>>> onclick="return
>>>> chkPair(document.getElementById('chkMaleWChildrenMin'))" runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px; HEIGHT: 64px">Single female with
>>>> children</TD>
>>>>    <TD STYLE="WIDTH: 51px; HEIGHT: 64px" align=center><asp:CheckBox
>>>> id=chkFemaleWChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkFemaleWChildrenMax'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD STYLE="HEIGHT: 64px" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkFemaleWChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkFemaleWChildrenMin'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Single male w/o children</TD>
>>>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkMaleWOChildrenMax runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>>> id=chkMaleWOChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkMaleWOChildrenMin'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD></TR>
>>>>  <TR>
>>>>    <TD STYLE="WIDTH: 293px">Single female w/o children</TD>
>>>>    <TD STYLE="WIDTH: 51px" align=center colSpan=1
>>>> rowSpan=1><asp:CheckBox id=chkFemaleWOChildrenMax onclick="return
>>>> chkPair(document.getElementById('chkFemaleWOChildrenMax'))"
>>>> runat="server" EnableViewState="False"></asp:CheckBox></TD>
>>>>    <TD align=center colSpan=1 rowSpan=1><asp:CheckBox
>>>> id=chkFemaleWOChildrenMin onclick="return
>>>> chkPair(document.getElementById('chkFemaleWOChildrenMax'))"
>>>> runat="server"
>>>> EnableViewState="False"></asp:CheckBox></TD></TR></TABLE>
>>>> <DIV STYLE="WIDTH: 664px; POSITION: relative; HEIGHT: 241px"
>>>> MS_POSITIONING="GridLayout">
>>>> <DIV
>>>> STYLE="DISPLAY: inline; Z-INDEX: 101; LEFT: 16px; WIDTH: 472px;
>>>> FONT-STYLE: italic; POSITION: absolute; TOP: 16px; HEIGHT: 24px"
>>>> MS_POSITIONING="FlowLayout">Pre-built Reports</DIV>
>>>> <DIV
>>>> STYLE="Z-INDEX: 102; LEFT: 0px; WIDTH: 664px; POSITION: absolute; TOP:
>>>> 48px; HEIGHT: 172px"
>>>> MS_POSITIONING="FlowLayout"><asp:RadioButtonList id=rblCannedRpts
>>>> onclick="return unCheckCustom(this.form)" runat="server" Width="640px"
>>>> EnableViewState="False"></asp:RadioButtonList>
>>>> <HR WIDTH="100%" SIZE=1>
>>>>
>>>> <DIV STYLE="WIDTH: 480px; POSITION: relative; HEIGHT: 112px"
>>>> MS_POSITIONING="GridLayout"><asp:button id=btnGenGraph style="Z-INDEX:
>>>> 101; LEFT: 152px; POSITION: absolute; TOP: 24px" runat="server"
>>>> Height="64px" Width="168px" Text="Generate
>>>> Graph"></asp:button></DIV></DIV></DIV></asp:panel></form>
>>>>
>>>>  </body>
>>>> </HTML>
>>>>
>>>> =============================================================================
>>>> =============================================================================
>>>>
>>>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>>>> news:O9AMBGoLGHA.3856@TK2MSFTNGP12.phx.gbl...
>>>>> So,
>>>>>
>>>>> how's the entire page's code like?
>>>>>
>>>>> --
>>>>> Teemu Keiski
>>>>> ASP.NET MVP, AspInsider
>>>>> Finland, EU
>>>>> http://blogs.aspadvice.com/joteke
>>>>>
>>>>> "astropup" <astro***@mn.rr.com> wrote in message
>>>>> news:q56Hf.1233$xZ4.764@tornado.rdc-kc.rr.com...
>>>>>>
>>>>>> no - but I've added that and it makes no difference...
>>>>>>
>>>>>> -)
>>>>>>
>>>>>> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>>>>>> news:e56%23EKmLGHA.208@tk2msftngp13.phx.gbl...
>>>>>>> Hi,
>>>>>>>
>>>>>>> does the initial populating happen inside If Not Page.IsPostback
>>>>>>> check? At which point do you check for the selection e.g in
>>>>>>> page_load, button_click etc?
>>>>>>>
>>>>>>> --
>>>>>>> Teemu Keiski
>>>>>>> ASP.NET MVP, AspInsider
>>>>>>> Finland, EU
>>>>>>> http://blogs.aspadvice.com/joteke
>>>>>>>
>>>>>>> "astropup" <astro***@mn.rr.com> wrote in message
>>>>>>> news:ts3Hf.551$CV.269@tornado.rdc-kc.rr.com...
>>>>>>>>
>>>>>>>> I'm trying to get the selected button in a radiobutton list....but
>>>>>>>> the selectedindex is always -1.    Any ideas what i'm doing wrong?
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>> ==================================
>>>>>>>> I've included the code that loads the radiobuttonList here:
>>>>>>>> ==================================
>>>>>>>> Private Sub loadrblCanRpts()
>>>>>>>>
>>>>>>>> Dim cnn As New SqlClient.SqlConnection
>>>>>>>> Dim cmd As New SqlClient.SqlCommand
>>>>>>>> Dim rbl As RadioButtonList = Me.rblCannedRpts
>>>>>>>> Dim sStr As String
>>>>>>>>
>>>>>>>> cnn.ConnectionString = gcsCnnStr
>>>>>>>> cmd.CommandType = CommandType.StoredProcedure
>>>>>>>> cmd.CommandText = "_sp_getCannedReports"
>>>>>>>> cmd.Connection = cnn
>>>>>>>>
>>>>>>>> Try
>>>>>>>>    cnn.Open()
>>>>>>>>    Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader
>>>>>>>>    While rdr.Read
>>>>>>>>        Dim itm As New ListItem(rdr.Item("cannedName"),
>>>>>>>> rdr.Item("spnames"))
>>>>>>>>        rbl.Items.Add(itm)
>>>>>>>>    End While
>>>>>>>>    rdr.Close()
>>>>>>>>    cnn.Close()
>>>>>>>> Catch ex As Exception
>>>>>>>>    Stop
>>>>>>>> End Try
>>>>>>>>
>>>>>>>> End Sub
>>>>>>>>
>>>>>>>> ==================================
>>>>>>>> The code that looks for the selected button is here:
>>>>>>>> ==================================
>>>>>>>>
>>>>>>>> Private Sub loadHashTable(ByVal acontainer As Object)
>>>>>>>>    'loop thru all controls on page - stuff all checkboxes or radio
>>>>>>>> button that are not null
>>>>>>>>    'into hashtable
>>>>>>>>
>>>>>>>>    Dim ctrl As Control
>>>>>>>>    For Each ctrl In acontainer.controls
>>>>>>>>        If ctrl.HasControls Then
>>>>>>>>            Call loadHashTable(ctrl)
>>>>>>>>        End If
>>>>>>>>        If TypeOf ctrl Is CheckBox Then
>>>>>>>>            With ctrl
>>>>>>>>                If CType(ctrl, CheckBox).Checked Then
>>>>>>>>                    mHT.Add(ctrl.ID, ctrl.ID)
>>>>>>>>                End If
>>>>>>>>            End With
>>>>>>>>        ElseIf TypeOf ctrl Is RadioButtonList Then
>>>>>>>>            If CType(ctrl, RadioButtonList).SelectedIndex <> -1 Then
>>>>>>>>                 Stop <<< never get to this point...selectedIndex is
>>>>>>>> always -1 !>>>
>>>>>>>>            End If
>>>>>>>>        End If
>>>>>>>> Next
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>