[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

AppendDataBoundItems Problem

Posted on 2008-10-15
4
Medium Priority
?
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Accepted Solution

by:
ghopkins66 earned 252 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 248 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

649 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