0

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()
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by __avd
0

Set SelectedValue property of RadioButtonList control.

...
 Me.rblprinter.DataBind()
 Me.rblprinter.SelectedValue="Name_of_Printer" 
...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.