CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > starter_kits_and_source_projects.portal_starter_kit Tags:
Item Type: Date Entered: 2/16/2004 3:03:34 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 31 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
"Laura D" <>
NewsGroup User
Me and my dropdown2/16/2004 3:03:34 PM

0

Hi,

Can I ask if this is the preferred method of dealing with dropdownlists and setting the selected item to a specific value contained in a record. If you imagine that I have a table of clubs and to edit a club I load a ClubEdit page. Now my regions dropdown list is set to the values within a region table like so when the page loads:


Dim regionlist As SqlDataReader = Regions.GetRegions()
cboRegion.DataSource = regionlist
cboRegion.DataValueField = "RegionID"
cboRegion.DataTextField = "Region"
cboRegion.DataBind()


Now when I want to load a particular club I want to set the values in any dropdown to the values in the club table i.e. the RegionID field and Region (name) from my query results ...


'set regionlist to the current value
With cboRegion
'add a default item to the dropdown
cboRegion.Items.Insert(0,"")
cboRegion.SelectedIndex = 0
.SelectedItem.Value = dr("RegionID")
.SelectedItem.Text = dr("Region")
End With


I find that if I do not use the
cboRegion.Items.Insert(0,"") ...etc
bit I simply end up overwriting the first item in the list so my dropdown contains all the items minus one.

So what I am asking is .... is this how you great wise ones deal with this??

Tips and tricks for my arsenal gratefully recieved.

Laura D


"wunderkinder"
NewsGroup User
Re: Me and my dropdown2/16/2004 5:16:03 PM

0

When the page loads, the first item in the dropdown list is selected by default (unless you specify otherwise). So, when you use this: .SelectedItem.Value = dr("RegionID"), it changes the value of of the selected item (item 0, or the first item). I do not think this is not what you are trying to accomplish. If I understand correctly, you are trying to select the the item in the dropdownlist that matches the current value. To accomplish this, you need to bind the list to the datasource, then loop through the list until you find a match for the current value.

Dim i as Integer
For i = 0 to cboRegion.Items.Count - 1
If cboRegion.SelectedItem.Value = dr("RegionID") then
cboRegion.SelectedIndex = i
End If
Next

Jared Livingston
MrLivingston.com - Livingston Family Website

Test/Demo site - moonmark.com
"Laura D" <>
NewsGroup User
Re: Me and my dropdown2/16/2004 7:03:19 PM

0

Hmm

Of course that looks so obvious!!! I should take a break from the screen sometimes and sit back and think a bit more ...

Thanks ....
"Laura D" <>
NewsGroup User
Re: Me and my dropdown2/16/2004 9:50:00 PM

0

Well ... I couldn't get that to work - always selects the first item in the list.

Got this to work though:


'set regionlist to the current value
dim selectedregion as integer
selectedregion = dr("RegionID")
cboRegion.Items.FindByValue(selectedregion).Selected = True


Not too sure why the previous method wouldn't work .. will ponder that on the train in the morning.

Laura D
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:













admin tab

creating multiple admins for different sections

printing contents of a module without printing the whole page.

get/set properties between modules on same page/tab

make parent portal pages visible to all child portals

where to find the "milestone" module

installed fine but it won't run

changing tabs programatically

how to make security role non-editable

modifying the userdb class

error in udt module

asp.net portal starter kit - siteconfiguration class

admin tab functions firing twice

connecting to the database

portal / windows authentication

problem with viewstate (request.urlreferrer ) in edit mode

confused by application_beginrequest in global.asax

.net webcontrols

compilation error

decision time

how to render internal/external html pages in the portal content

how do you handle dynamic linkbuttons

display current date/time

portal is extremely buggy

strange behavior in ibuyspy portal?

data driven custom controls?

i need an alert/warning/confrim box

how to add additional portals?

which portal?

error: loading asp.net portal (csvs) installer v1.0.msi

do you need iis to run ibuyspyportal?

bug: adding on tabs and deleting newly created ones

front page server extensions and portal

created a new module using datalist (similiar to users) and imagebutton will not use itemcommand

could not find installable isam

is there some other version of ibs that i can't find?

removing the mobil functionality from the portal

enhanced document library for asp.net portal starter kit (better than the default)

how to get the "email" after ibs created the authenticationticket?

configuration error

install problem -- iis and msde on different servers

adding htmlanchor dynamically

object reference not set to an instance of an object

announcements module. read more implementation

error in installing ibuyspy portal

i can not enter the admin pages

portal sdk not authorised to view this page msg.

customization

can't get custom error messages to work

slight database connection problem

   
  Privacy | Contact Us
All Times Are GMT