Solved

drop down list databind with new item inserted in detailsview

Posted on 2014-01-30
3
833 Views
Last Modified: 2014-01-31
On my page I have two object data sources; the first has a bound drop down
list, with an item number and a description. The second has a bound details view showing
everything for the item number.

Selecting an item in the drop down list, causes the details to be shown, as
intended. When I insert a new record from the details view, I want to add it
to the drop down list and select it.

I tried to just do a:

Private Sub dvRecipeItem_ItemInserted(sender As Object, e As DetailsViewInsertedEventArgs) Handles dvRecipeItem.ItemInserted
    ddRecipeItemNumber.DataBind()
End Sub

And even though Databind does load the newly added item to the drop down list, it does not make it the selected value, thus the record displayed on the details view is just whichever item number is first since it is ordered by item number

can some one explain me how to make it work for the scenario i described on the second paragraph?

thank you very much.
0
Comment
Question by:metropia
[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
3 Comments
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 250 total points
ID: 39823455
You must select the item manually.

ddRecipeItemNumber.DataBind()
ddRecipeItemNumber.SelectedValue = ...

You can use e.Values to obtain a dictionary with the field name/value pairs for the inserted record. Then set the SelectedValue property of your DropDownList to the appropiate value.

Hope that helps.
0
 
LVL 13

Accepted Solution

by:
jitendra patil earned 250 total points
ID: 39823458
hi

as you said
even though Databind does load the newly added item to the drop down list, it does not make it the selected value

unless and until you provide a  selected value to the dropdownlist it will display the first coming record only.

you need to assign a selected value to the droplist and accordingly update the details view also.

to do that you can have a newly added value in a public variable on .vb page and assign the selected value of dropdown with the variable value.

now again rebind your detail view wih the selected value of dropdownlist.

hope this helps.
0
 

Author Comment

by:metropia
ID: 39824146
"You can use e.Values to obtain a dictionary with the field name/value pairs for the inserted record. Then set the SelectedValue property of your DropDownList to the appropiate value."

Would you be able to show me how to do this?

Thank you.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

688 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