troubleshooting Question

Dynamic radio button

Avatar of Chris Jones
Chris JonesFlag for United States of America asked on
.NET ProgrammingASP.NETVisual Basic.NET
5 Comments1 Solution427 ViewsLast Modified:
Hello,

i have a dynamic radio button list i am pulling form a database when i click my next button on my page the i an not sure how i get my value that was selected form that dynamic radio button. i started to use find control. some code is attached.
    ' displays the list of search 
    Private Sub buildsearch()

        Dim i As Integer ' counter
        Dim sql As New SqlCommand
        Dim conn As SqlConnection
        Dim dr As SqlDataReader

        Dim categoryname As String = ""
        Dim r As TableRow ' create a new row
        Dim c As TableCell ' create a new cell
        Dim t As Table = New Table ' make a new table
        Dim ct As Integer = 0
        Dim ID As String

        ' initilizes the connection and starts the SQl tasks
        conn = NewSQLConnectionWebApp()
        sql.Connection = conn
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        sql.CommandText = "SELECT ID,CategoryType FROM Category WHERE CategoryType Like  '%" & Replace(search.Text, "'", "''") & "%'AND ValidationStatus =  '" & "Y" & "' order by CategoryType"
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        dr = sql.ExecuteReader


        ' creates dymanic table 
        t = New Table
        t.Width = Unit.Percentage(100)
        ' creates the table for the diplay 
        r = New TableRow
        r.VerticalAlign = VerticalAlign.Top
        r.CssClass = "StandardRowHeader"
        c = New TableHeaderCell
        c.Text = "Select"
        r.Controls.Add(c)
        t.Controls.Add(r)


        While dr.Read()
            categoryname = dr("CategoryType")
            Global_Category_ID = dr("ID")
            r.Controls.Add(c)
            t.Controls.Add(r)
            r = New TableRow
            ct += 1
            If ct Mod 2 = 0 Then
                r.CssClass = "StandardRowEven"
            Else
                r.CssClass = "StandardRowOdd"
            End If
            '   Call CellAdd(r, categoryname)
            Call WebCellRadioNew(r, Global_Category_ID, "Category", 1, categoryname, False)
            Category_Array(i) = Global_Category_ID
            globalcount = globalcount + 1
            t.Controls.Add(r)
        End While
        PR.Controls.Add(t)
        dr.Close()
        sql.Dispose()
        conn.Close()
    End Sub
    'This function gets the logged in basic information of particular user
    Protected Function LoggedInBasicInfo()
        Dim username As String = ""
        username = Session("USER")
        Dim sql As New SqlCommand
        Dim conn As SqlConnection
        Dim dr As SqlDataReader
        Dim firstname As String = ""
        Dim lastname As String = ""
        Dim primaryphone As String = ""
        Dim cellphone As String = ""
        Dim emailid As String = ""
        Dim address As String = ""
        Dim city As String = ""
        Dim state As String
        Dim zip As String = ""
        Dim country As String = ""
        Dim title As String
       
        ' initilizes the connection and starts the SQl tasks
        conn = NewSQLConnectionWebApp()
        sql.Connection = conn
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        sql.CommandText = "SELECT * FROM BasicInfo WHERE UserName = '" & username & "'"
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        ' open the database
        dr = sql.ExecuteReader
        ' read the data rows
        While dr.Read()
            firstname = dr("FirstName")
            lastname = dr("LastName")
            primaryphone = dr("PrimaryPhone")
            cellphone = dr("CellPhone")
            emailid = dr("EmailID")
            address = dr("Address")
            city = dr("City")
            state = dr("State")
            zip = dr("Zip")
            country = ""
            title = dr("Title")

        End While


        ' Find the checkbox the yusers checked to get there category type 
        Dim RadioButtonCategory As RadioButton
        For i = 0 To globalcount
            RadioButtonCategory = PR.FindControl(Category_Array(i))

            If RadioButtonCategory.Checked = True Then
                FundName.Text = RadioButtonCategory.Text
            End If


        Next


        ' load the value sinto the summary view this sould be optomized  in the next version
        DropDownList4.Text = title
        txtFname.Text = firstname
        txtLname.Text = lastname
        txtAddress.Text = address
        txtCity.Text = city
        txtstate.Text = state
        txtZip.Text = zip
        txtPphone.Text = PhoneFormat(primaryphone)
        txtCphone.Text = PhoneFormat(cellphone)
        txtEmail.Text = emailid


        dr.Close()
        sql.Dispose()
        conn.Close()
        Return Nothing
    End Function
ASKER CERTIFIED SOLUTION
MlandaT

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros