Solved

AppendDataBoundItems Problem

Posted on 2008-10-15
4
300 Views
Last Modified: 2013-12-17
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.

0
Comment
Question by:pr_wainwright
  • 2
4 Comments
 

Accepted Solution

by:
ghopkins66 earned 63 total points
ID: 22720844
Hello Paul,

I may be missing something here but if you want only the four static ListItems declared in the code above then why do you need to DataBind at all? I think you should get rid of the DataSourceID field.

Regards,
Gareth


0
 
LVL 15

Assisted Solution

by:NazoUK
NazoUK earned 62 total points
ID: 22720869
If you want those 4 static items only, I'm not sure why you are databinding the list at all? Just get rid of the AppendDataBoundItems="True" DataSourceID="SqlDataSource1" DataTextField="StandardNumber" DataValueField="StandardNumber" altogether
0
 
LVL 1

Author Comment

by:pr_wainwright
ID: 22724338
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.
                                 
0
 

Expert Comment

by:ghopkins66
ID: 22726467
It's the SelectedValue='<%# Bind("StandardNumber") %>' that will link the field to the control. Just try removing the tags that NazoUK has commented.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now