Netnoobie
Well-known member
I have a datagrid pulling a few records in at a time, and in the query is a location ID and container ID. In the datbase the IDs refer to names, and so on.
The problem Im having is that I can display the related text of the id by running a query in the Label tag, but when the user goes to edit the row, i need the dropdowns that appear to contain the Text of the IDs, not the IDs. But I keep getting an error when I try to do anything with the data that I think stems from the initial query that binds the datagrid having the ID and not the Text.
Heres an example of the HTML for one of the DDLs in the edite template:
The Bind DDL Function for this item looks like:
And the GetSelIndex does just that, gets the default item out of the list based on what the database returns:
Now Ive done all of this many times with datagrids when I dont have to translate the data. But now when do I get all kinds of problems stemming from the fact that the Text Im searching for is not in the original query.
I cant see how this would be acceptable like this...has any done this before? I can post more code if needed.
Thank you very much.
The problem Im having is that I can display the related text of the id by running a query in the Label tag, but when the user goes to edit the row, i need the dropdowns that appear to contain the Text of the IDs, not the IDs. But I keep getting an error when I try to do anything with the data that I think stems from the initial query that binds the datagrid having the ID and not the Text.
Heres an example of the HTML for one of the DDLs in the edite template:
Code:
<asp:DropDownList runat="server" id="selLocation" DataSource=<%# BindDDL("Location") %> SelectedIndex=<%# GetSelIndex(Container.DataItem("LocNum"), "Location") %> />
The Bind DDL Function for this item looks like:
Code:
Const strSQLDDL As String = _
"SELECT RepoLocation FROM Location WHERE Repo = 1 ORDER BY RepoLocation"
Dim myDataAdapter As OdbcDataAdapter = New OdbcDataAdapter(strSQLDDL, objConnection)
myDataAdapter.Fill(ddlLocationDS, "LocationDS")
Return ddlLocationDS
And the GetSelIndex does just that, gets the default item out of the list based on what the database returns:
Code:
Dim objDT As DataTable = BindDDL("Location").Tables("LocationDS")
For iLoop = 0 To objDT.Rows.Count - 1
If ConvertNumber(Item, "Location") = objDT.Rows(iLoop)("RepoLocation") Then
Return iLoop
End If
Next iLoop
objDT = Nothing
Now Ive done all of this many times with datagrids when I dont have to translate the data. But now when do I get all kinds of problems stemming from the fact that the Text Im searching for is not in the original query.
I cant see how this would be acceptable like this...has any done this before? I can post more code if needed.
Thank you very much.