So I have a radiobuttonlist that returns a list based on a sql query. The app displays the results from the column named "printer". I am also selecting the column_name "default_printer" Basically what I want is for the selected index of the radiobuttonlist to be where "Default_Printer" = "1". I'm not exactly sure how to do this any help would be appreciated. my code looks like this

Private Sub BuildPrinterList(ByVal Warehouse As String)
        Try
            Dim strConnString As String
            strConnString = ConfigurationManager.ConnectionStrings("SDWConnectionString").ToString

            Dim SqlCOnnection As New SqlConnection(strConnString)
            SqlCOnnection.Open()

            Dim strSQLText As String

            strSQLText = "SELECT Distinct Printer, Default_Printer from sdw.sdw_user.sar_dtd_840_Printer_Label where Warehouse = '" & Warehouse & "'"

            Dim sqlCmd As New SqlCommand(strSQLText, SqlCOnnection)

            Dim adapter As New SqlClient.SqlDataAdapter(strSQLText, strConnString)

            Dim ds As New DataSet
            adapter.Fill(ds, "printers")
            Dim dataTable = ds.Tables("printers")

            Me.rblprinter.DataSource = dataTable

            Me.rblprinter.DataValueField = "Printer"
            Me.rblprinter.DataTextField = "Printer"

            Me.rblprinter.DataBind()

            Me.rblprinter.SelectedIndex = 'statement saying where default_printer = 1

            SqlCOnnection.Close()

Set SelectedValue property of RadioButtonList control.

...
 Me.rblprinter.DataBind()
 Me.rblprinter.SelectedValue="Name_of_Printer" 
...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.