Hi-
I have this code:
Here is the code for the radiobutton:
I'm trying to retrieve a value from a SQL table using a datareader to populate the radiobuttonlist with that value so when they edit their data, they can see what they previously chose... but this is producing nothing- any ideas???
Thanks...
When I write Result("CurrentStatus").ToString I get the value of 300 which is "In Progress" so I want to show that in the radiobuttonlist, it's coming up blank,not pulling anything from the db...
I have this code:
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
Here is the code for the radiobutton:
Code:
'CurrentStatus.SelectedValue = Result("CurrentStatus").ToString()
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
myConn.Close()
End If
I'm trying to retrieve a value from a SQL table using a datareader to populate the radiobuttonlist with that value so when they edit their data, they can see what they previously chose... but this is producing nothing- any ideas???
Thanks...
When I write Result("CurrentStatus").ToString I get the value of 300 which is "In Progress" so I want to show that in the radiobuttonlist, it's coming up blank,not pulling anything from the db...