Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DropDownList SelectedItem?DropDownList SelectedItem?
Previous
 
Next
New Post
11/1/2007 12:24 PM
 



I am working with an Unbound DropDownList that is binding from sql table.
Having done the same process with ListBoxes, I am becoming familiar with the necessary elements.
DataTextField, DataValueField, DataMember, AppendDataBound are all set correct.

I am running into an issue, where running one style of code works 50% correct, the other style works 50% correct, yet I need both functions.
The goal is to have the selected item from within the DropDownList (upon user clicking button) be dynamically used elsewhere.

The DataBind is working correctly, but after each "button clicked event", the binded data was doubling, tripling, quad. etc....
I had run into this problem prior with a ListBox and corrected easily by doing: ListBox.Items.Clear()
 

OPTION 1: Presently, if I use the code with the DropDownList.Tems.Clear(), the selected item doesn't matter. It is grabbing the first index (which is my problem), but does remove duplicate data from databind by clearing items correctly.

OPTION 2:
If I remove the DropDownList.Tems.Clear(), it does grab the selected items text correctly, but binds the data double, triple, quad. etc.... upon button clicks.

It seems like the DropDownList should work the same as the ListBoxes, but there must be something I am overlooking.

I have also tried using myParam method in both Selected.Text & Selected.Value format, but it doesn't seem to need this, since OPTION 2 works without:
Dim myParam As SqlParameter = New SqlParameter("@myParam", SqlDbType.Nvarchar, 100)
myParam.Value = DropDownList.SelectedItem.Text


What do I need to do, so OPTION 1 works correctly and doesn't select the first index of the DropDownList?
or
What do I need to do, so OPTION 2 works correctly and doesn't include duplicate databind data?

 

Feedback Appreciated,

-machina12 

 
New Post
11/1/2007 1:21 PM
 

Forget your two options.  The standard method is to always test for isPostBack on page load and page init, and only do binding when it is false.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DropDownList SelectedItem?DropDownList SelectedItem?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out