Hi Dan, thanks for the reply. Here is my code showing functions to populate the dataset and to get the selected row. StatusID is the primary key in my access database & thought I'd need to use it to default the value of the dropdownlist to the current value.
Function GetStatus() as DataSet
Dim DBConn as OleDbConnection
Dim DBCommand as OleDbDataAdapter
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("data/Auto\_log.mdb") & ";")
DBCommand = New OleDbDataAdapter("SELECT StatusID, Status from Status ORDER BY Status", DBConn)
DBCommand.Fill(DS, "Status")
DBConn.Close()
Return DS
End Function
Function GetSelectedIndex(ByVal StatusID As String) As Integer
'Loop through the DataSet DS
Dim iLoop As Integer
Dim DT As DataTable = DS.Tables("Status")
For iLoop = 0 To DT.Rows.Count - 1
If StatusID = DT.Rows(iLoop)("StatusID").ToString Then
Return iLoop
End If
Next iLoop
End Function
I then declare the ddl in my update subroutine as follows
Dim ddlStatus As DropDownList = FindControl("ddlStatusctrl")
and here is the ddl control from my datagrid:
Status
<%# Container.DataItem("Status") %>
Rob