lorena
Centurion
I hava a datagrid that I am setting up for editing. Two fields have a limited selection of values so the cells with those fields are set up as dropdowns when "Edit" is clicked.
I am having a problem setting the initial value for the dropdown list. The values load into the list okay but I can't figure out how to make the initial value in the dropdown match the value of the database field.
Here is the code for the datagrid row:
<asp:TemplateColumn HeaderText="Type">
<ItemTemplate><asp:Label Runat="server" id="lblType"
Width="60px" text='<%# DataBinder.Eval(Container.DataItem, "Type") %>'/></ItemTemplate>
<EditItemTemplate>
<aspropDownList Runat="server" ID="ddlType" Font-Name="Verdana" Font-Size="xx-small" DataTextField="Type" DataValueField="Type" DataSource="<%# GetTypes() %>">
</aspropDownList></EditItemTemplate></asp:TemplateColumn>
This is the code for the function that fills the dropdown:
Function GetTypes() As DataSet
Const strSQLT As String = "Select DISTINCT Type from toolroom"
Dim objConn As New OleDb.OleDbConnection(strConnString)
Dim myDA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(strSQLT, objConn)
myDA.Fill(ddlType, "toolroom")
objConn.Close()
Return ddlType
End Function
Any suggestions would be appreciated
I am having a problem setting the initial value for the dropdown list. The values load into the list okay but I can't figure out how to make the initial value in the dropdown match the value of the database field.
Here is the code for the datagrid row:
<asp:TemplateColumn HeaderText="Type">
<ItemTemplate><asp:Label Runat="server" id="lblType"
Width="60px" text='<%# DataBinder.Eval(Container.DataItem, "Type") %>'/></ItemTemplate>
<EditItemTemplate>
<aspropDownList Runat="server" ID="ddlType" Font-Name="Verdana" Font-Size="xx-small" DataTextField="Type" DataValueField="Type" DataSource="<%# GetTypes() %>">
</aspropDownList></EditItemTemplate></asp:TemplateColumn>
This is the code for the function that fills the dropdown:
Function GetTypes() As DataSet
Const strSQLT As String = "Select DISTINCT Type from toolroom"
Dim objConn As New OleDb.OleDbConnection(strConnString)
Dim myDA As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(strSQLT, objConn)
myDA.Fill(ddlType, "toolroom")
objConn.Close()
Return ddlType
End Function
Any suggestions would be appreciated