I have this code:
for my Datareader
Then I have:
for my radiobutton- I'm trying to get a value from the database and populate the radiobuttonlist with it to show what the user previously selected-- Any ideas????
It's not working...
Thanks...
Code:
If Not Page.IsPostBack Then
'Define connection to read the data
Dim myConn As New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
Dim MyCmd As New SqlCommand("SELECT [VendorID],[DivisionName],[DeptName],[VendorName],[VendorCode],
[CurrentStatus],[Joined],[SKU],[EDI],[RBT],[ContactName],[ContactPhone],
[ContactFax],[EmailAddress]FROM [ENAPTEST].[dbo].[tblVendorInfo] Where VendorID = @VendorID", myConn)
MyCmd.CommandType = CommandType.Text
MyCmd.Parameters.Add(New SqlParameter("@VendorID", SqlDbType.Int, 4)).Value = Convert.ToString(VendorID)
myConn.Open()
'Read the data
Dim Result As SqlDataReader = MyCmd.ExecuteReader(CommandBehavior.CloseConnection)
Result.Read()
VendorNumber.Text = Result("VendorID").ToString()
If Not Result.IsDBNull(0) Then
DivisionName.Text = Result("DivisionName").ToString()
End If
If Not Result.IsDBNull(0) Then
DeptName.Text = Result("DeptName").ToString()
End If
If Not Result.IsDBNull(0) Then
VendorName.Text = Result("VendorName").ToString()
End If
If Not Result.IsDBNull(0) Then
VendorCode.Text = Result("VendorCode").ToString()
End If
If Not Result.IsDBNull(0) Then
Joined.Text = Result("Joined").ToString()
End If
If Not Result.IsDBNull(0) Then
SKU.Text = Result("SKU").ToString()
End If
If Not Result.IsDBNull(0) Then
EDI.Text = Result("EDI").ToString()
End If
If Not Result.IsDBNull(0) Then
RBT.Text = Result("RBT").ToString()
End If
If Not Result.IsDBNull(0) Then
ContactName.Text = Result("ContactName").ToString()
End If
If Not Result.IsDBNull(0) Then
ContactPhone.Text = Result("ContactPhone").ToString()
End If
If Not Result.IsDBNull(0) Then
ContactFax.Text = Result("ContactFax").ToString()
End If
If Not Result.IsDBNull(0) Then
EmailAddress.Text = Result("EmailAddress").ToString()
End If
for my Datareader
Then I have:
Code:
Dim radList As RadioButtonList
radList = CType(FindControl("CurrentStatus"), RadioButtonList)
Do While Result.Read()
Dim CurrentSelect As ListItem
CurrentSelect = radList.Items.FindByValue(Result("CurrentStatus").ToString())
If Not CurrentSelect Is Nothing Then
CurrentSelect.Selected = True
End If
Loop
for my radiobutton- I'm trying to get a value from the database and populate the radiobuttonlist with it to show what the user previously selected-- Any ideas????
It's not working...
Thanks...