lorena
Centurion
I have a table that populates a datagrid for a user to edit.
When the user clicks "Edit", one of the columns needs to be a dropdown list so only certain choices will be entered in the database.
The list only has 5 values and I want to call a function which creates an array or arraylist to populate the dropdown.
I am having a problem because the dropdown control doesn't actually exist until the user clicks Edit so I am having problems referring to it by code.
Here is the template code for the template column:
<asp:TemplateColumn HeaderText="Type">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Type") %>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList Runat="server" ID="ddlType" DataValueField="Type" DataSource="<%# GetTypes() %>">
</aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
And this is the function code(so far):
Function GetTypes() As DataSet
Dim oTypes As New ArrayList()
oTypes.Add("PROD")
oTypes.Add("TOOL")
oTypes.Add("REWORK")
oTypes.Add("SHOP AID")
oTypes.Add("PROTO")
End Function
How do I bind this array to the dropdown control? I cannot do it inline with the control because I need to set the selected value for the dropdown to the value contained in the cell (and the unedited record).
I hope I am making sense.
Any help would be appreciated.
Thanks in advance
When the user clicks "Edit", one of the columns needs to be a dropdown list so only certain choices will be entered in the database.
The list only has 5 values and I want to call a function which creates an array or arraylist to populate the dropdown.
I am having a problem because the dropdown control doesn't actually exist until the user clicks Edit so I am having problems referring to it by code.
Here is the template code for the template column:
<asp:TemplateColumn HeaderText="Type">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Type") %>
</ItemTemplate>
<EditItemTemplate>
<aspropDownList Runat="server" ID="ddlType" DataValueField="Type" DataSource="<%# GetTypes() %>">
</aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
And this is the function code(so far):
Function GetTypes() As DataSet
Dim oTypes As New ArrayList()
oTypes.Add("PROD")
oTypes.Add("TOOL")
oTypes.Add("REWORK")
oTypes.Add("SHOP AID")
oTypes.Add("PROTO")
End Function
How do I bind this array to the dropdown control? I cannot do it inline with the control because I need to set the selected value for the dropdown to the value contained in the cell (and the unedited record).
I hope I am making sense.
Any help would be appreciated.
Thanks in advance