Link to home
Start Free TrialLog in
Avatar of pr_wainwright
pr_wainwright

asked on

AppendDataBoundItems Problem

Hi,

I have a DropDownList box configured as shown below. When my DetailsView is in Edit or Insert mode I only want the 4 list items listed below to appear. If I have AppendDataBoundItems set to true I get the list items multiple times from other records in the table (I guess). If I set AppendDataBoundItems to false I only get 1 item in the list (the same as the current record). How can I make it so that the list is always the 4 items only?.

<EditItemTemplate>

OnSelectedIndexChanged="ddlStandardNumber_SelectedIndexChanged" Width="220px" AutoPostBack="True">          
                    <asp:DropDownList ID="ddlStandardNumber" runat="server" AppendDataBoundItems="True"
                        DataSourceID="SqlDataSource1" DataTextField="StandardNumber" DataValueField="StandardNumber"
                        SelectedValue='<%# Bind("StandardNumber") %>' OnSelectedIndexChanged="ddlStandardNumber_SelectedIndexChanged" Width="220px" AutoPostBack="True">
                        <asp:ListItem>BGA-ENG-INST-TS-0001</asp:ListItem>
                        <asp:ListItem>BGA-ENG-INST-TS-0003</asp:ListItem>
                        <asp:ListItem>BGA-ENG-ELEC-TS-0001</asp:ListItem>
                        <asp:ListItem>BGA-ENG-ELEC-TS-0002</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>

Any help appreciated.

Thanks
Paul.

ASKER CERTIFIED SOLUTION
Avatar of ghopkins66
ghopkins66

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pr_wainwright
pr_wainwright

ASKER

ghopkins66/NazoUK,
                                 I am new to ASP.NET, If I don't databind will the table field be updated with the selected item from the list?. I must be mistaken at what databinding does.

Thanks
Paul.
                                 
It's the SelectedValue='<%# Bind("StandardNumber") %>' that will link the field to the control. Just try removing the tags that NazoUK has commented.