[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Bind RadioButtonList with Access DB at runtime

Posted on 2006-04-20
1
Medium Priority
?
447 Views
Last Modified: 2011-10-03
I can't figure out what I'm doing wrong to bind the value from my access db to the radiobuttonlist.  Please help.

Code Behind:

    Private Sub getUserInfo()
        Dim objConn As New System.Data.OleDb.OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings("DSN"))
        Dim objCmd As System.Data.OleDb.OleDbCommand
        Dim dr As System.Data.OleDb.OleDbDataReader

        objCmd = New System.Data.OleDb.OleDbCommand("SELECT fname, lname, username, street, city, state, zipcode, phone, email, newsletter, moviereviews, christiananswers FROM Members WHERE UserName=@username", objConn)
        objCmd.Parameters.Add("@username", User.Identity.Name)

        Try

            objConn.Open()
            dr = objCmd.ExecuteReader

            If dr.HasRows Then
                dr.Read()
                txtFName.Text = SNH(dr.Item("fname"))
                txtLName.Text = SNH(dr.Item("lname"))
                lblUserName.Text = SNH(dr.Item("username"))
                txtStreet.Text = SNH(dr.Item("street"))
                txtCity.Text = SNH(dr.Item("city"))
                txtState.Text = SNH(dr.Item("state"))
                txtZip.Text = SNH(dr.Item("zipcode"))
                txtPhone.Text = SNH(dr.Item("phone"))
                txtEmail.Text = SNH(dr.Item("email"))
      rdnewsletter.SelectedItem.Value = SNH(dr.Item("newsletter"))
      rdmoviereviews.SelectedItem.Value = SNH(dr.Item("moviereviews"))
      rdchristiananswers.SelectedItem.Value = SNH(dr.Item("christiananswers"))
            End If
            objConn.Close()

        Catch ex As System.Exception
            lblResult.Text = "There was an error accessing your account: " & ex.Message
            lblResult.ForeColor = System.Drawing.Color.Red
        End Try

    End Sub

    Private Function SNH(ByVal arg As Object) As String
        If Microsoft.VisualBasic.IsDBNull(arg) Then Return String.Empty
        Return Microsoft.VisualBasic.Trim(CType(arg, String))
    End Function

-----------------------------------

RadioButtonList:

<asp:RadioButtonList DataMember="Members" DataTextField="newsletter" DataValueField="newsletter" DataSource='<%# DataBinder.Eval(Container, "newsletter" )%>' ID="rdnewsletter" runat="server" RepeatDirection="Horizontal"></asp:RadioButtonList>
0
Comment
Question by:azyet24
1 Comment
 
LVL 5

Accepted Solution

by:
bullrout earned 2000 total points
ID: 16515376
HI there,

There is heaps of articles on this, have a look see how you go. It's 2am where I live so i'm going to bed. I should be online tomorrow.

Sean

http://www.4guysfromrolla.com/webtech/072701-1.shtml
http://www.learnasp.com/freebook/learn/listbinding.aspx
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question