Yorkshire Divers

Deep Blue Technical
Go Back   YD Scuba Diving Forums > Non-Diving Related Forums > Technology
User Name
Password

Welcome to the YD Scuba forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Technology: Discuss ASP.NET Control Question in the Non-Diving Related Forums forums: OK, have wracked my brain (what little there is to wrack!) and I'm flummaxed, although it seems to be something ...

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 23-10-06, 05:17 PM
MartinS's Avatar
Senior Member
 

Join Date: Jul 2002
Location: Redhill, Surrey
Posts: 1,552
MartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the sea
ASP.NET Control Question

OK, have wracked my brain (what little there is to wrack!) and I'm flummaxed, although it seems to be something that I can't believe is not doable easily!
I have, on an aspx page, a drop-down control, which contains a list - the text and value fileds are different, i.e.
Text Value
Survey 1 1
Survey 2 2
...
Now, selecting an entry by value is easy, but how do I select by text instead?
As I have said, it seems too obvious to not be easy, but I cannot for the life of me think of the answer.
My intention is to select an item from this control based on the contents of a dataset, but what is in the dataset is the text, not the value, so the following code doesn't work:
Code:
this.ddlAppID.SelectedValue = m_DS.Tables[0].Rows[aRecordNumber].ItemArray.GetValue(1).ToString();
 
Can anyone help put me out of my misery..please?
Thanks in advance
Martin
__________________
Never test the depth of the water with both feet!
69 Divers SAC
Yorkshire Divers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 23-10-06, 05:48 PM
Fodder's Avatar
New Member
 

Join Date: Sep 2006
Posts: 20
Fodder dips toes in sea annuallyFodder dips toes in sea annuallyFodder dips toes in sea annuallyFodder dips toes in sea annuallyFodder dips toes in sea annuallyFodder dips toes in sea annuallyFodder dips toes in sea annuallyFodder dips toes in sea annuallyFodder dips toes in sea annuallyFodder dips toes in sea annuallyFodder dips toes in sea annually
not used asp.net but asp you could access control.text

but the fact that you are facing this data-translation problem suggests you've missed a trick OO-wise.

the only reason to have value and text different and using the text for lookup is if you are using the value for another lookup or calculation. This is a "hack" and should be avoided because what do you do when you need to apply a third piece of logic and neither your text nor value are suitable?

You need to model the relationship between your menu choices and table keys in either an object or an intermediate table.

Another problem with your current solution is that it breaks down if the text in your table is not suitable for presentation in an html control

oh, and searching tables using text is yuk

HTH
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 24-10-06, 08:38 AM
MartinS's Avatar
Senior Member
 

Join Date: Jul 2002
Location: Redhill, Surrey
Posts: 1,552
MartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the seaMartinS paddles in the sea
Quote:
Originally Posted by Fodder
not used asp.net but asp you could access control.text

but the fact that you are facing this data-translation problem suggests you've missed a trick OO-wise.

the only reason to have value and text different and using the text for lookup is if you are using the value for another lookup or calculation. This is a "hack" and should be avoided because what do you do when you need to apply a third piece of logic and neither your text nor value are suitable?

You need to model the relationship between your menu choices and table keys in either an object or an intermediate table.

Another problem with your current solution is that it breaks down if the text in your table is not suitable for presentation in an html control

oh, and searching tables using text is yuk

HTH
Hi
Thanks for the above. I was actually just trying to add some additional (useful) info to a screen, but it appears that it's not going to be possible, and as you say, will not really fit in with anything else.
Thanks anyway
Regards
Martin
__________________
Never test the depth of the water with both feet!
69 Divers SAC
Yorkshire Divers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Sponsored Links

Yorkshire Divers - RSS Feed
All times are GMT +1. The time now is 03:05 AM.
Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Trademark and all rights reserved : © YD.com Ltd (2006)
YD.com Ltd (Registered in England - 05886696)
Other sites : Golf Clubs | New Premiership Football Kits | MP3 Portable Players | MP3 Players For Sale | Replica Football Kits | Cheap Football Boots

Forums Directory