D
David C
Can someone help me figure out how to add entries to a DropDownList control
"on-the-fly"? I have a FormView with several DropDownList controls that are
bound to differnt lookup table in a SQL Server database. I have no problem
with code to add a record to the bound table but am getting errors every
time I try to set the SelectedValue to the new ID number of the added record
in the Page_Load event. Below is an example control and DataSource I have
for one of the DDL's. Thank you.
David
<aspropDownList ID="ddlAgentID" runat="server" DataSourceID="SqltlkpAgent"
DataTextField="Agent" DataValueField="AgentID"
SelectedValue='<%# Bind("AgentID") %>' Width="300"
AppendDataBoundItems="true">
<asp:ListItem Value="-1" Text="<<New Agent>>"></asp:ListItem>
</aspropDownList>
<asp:SqlDataSource ID="SqltlkpAgent" runat="server" ConnectionString="<%$
ConnectionStrings:FiledataConnectionString %>"
SelectCommand="SELECT 0 As AgentID, NULL As Agent UNION SELECT [AgentID],
[Agent] FROM [tlkpAgent] ORDER BY [Agent]">
</asp:SqlDataSource>
"on-the-fly"? I have a FormView with several DropDownList controls that are
bound to differnt lookup table in a SQL Server database. I have no problem
with code to add a record to the bound table but am getting errors every
time I try to set the SelectedValue to the new ID number of the added record
in the Page_Load event. Below is an example control and DataSource I have
for one of the DDL's. Thank you.
David
<aspropDownList ID="ddlAgentID" runat="server" DataSourceID="SqltlkpAgent"
DataTextField="Agent" DataValueField="AgentID"
SelectedValue='<%# Bind("AgentID") %>' Width="300"
AppendDataBoundItems="true">
<asp:ListItem Value="-1" Text="<<New Agent>>"></asp:ListItem>
</aspropDownList>
<asp:SqlDataSource ID="SqltlkpAgent" runat="server" ConnectionString="<%$
ConnectionStrings:FiledataConnectionString %>"
SelectCommand="SELECT 0 As AgentID, NULL As Agent UNION SELECT [AgentID],
[Agent] FROM [tlkpAgent] ORDER BY [Agent]">
</asp:SqlDataSource>