Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jhermiz
3564 Posts |
Posted - 2005-05-13 : 13:11:16
|
I am using the datalist and want to retrieve the datalistkey based on the text portion.For instance I have a CategoryID (primary key)Category (just text of the category)For example data:1 Electronics2 Manufacturing3 OtherWhen I bind the datalist it properly places the Text and hides the data key fine and dandy...But let us say I have "Electronics" the text portion, how do I retrieve the key value from the datalist given the text value ? Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]Imperfection living for perfection -- [url]http://jhermiz.blogspot.com/[/url] |
|
jhermiz
3564 Posts |
Posted - 2005-05-13 : 13:35:32
|
I can get the text with:Response.Write(CType(CType(e.Item.FindControl("lbParent"), LinkButton).Text, String))Now I would like to get the ParentID of this text...meaning associate the ParentID with this string... Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]Imperfection living for perfection -- [url]http://jhermiz.blogspot.com/[/url] |
 |
|
jhermiz
3564 Posts |
Posted - 2005-05-13 : 16:03:56
|
Ended up just passing a parameter and grabbing the key that will work for now.Jon Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]Imperfection living for perfection -- [url]http://jhermiz.blogspot.com/[/url] |
 |
|
olay80
Yak Posting Veteran
62 Posts |
Posted - 2005-05-16 : 08:47:40
|
Jon,i haven't worked much with datalist s but i've worked with dropdown s, but i think they work the same. the dropdownlist has a 'text' and a 'value' when i bind data to it i can assign the 'text' to a ceratin column and the 'value' to another column it only shows the text but i can always retrieve the value. Oliver |
 |
|
jhermiz
3564 Posts |
Posted - 2005-05-16 : 08:49:44
|
But that wasnt my question, my question was given the text how can i retrieve the id? Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]Imperfection living for perfection -- [url]http://jhermiz.blogspot.com/[/url] |
 |
|
olay80
Yak Posting Veteran
62 Posts |
Posted - 2005-05-16 : 10:31:39
|
if u only have the text u can set an sql to retrieve the id upon each text result (the text should be unique),or change ur design in a way that if ur getting the text from a table directly select it with the id join them in one string in a specific format (ex: 1-Electronics) that's how the text in the dataGrid should look like and then split them upon retrieving the values. hope i understood u well.Oliver |
 |
|
jhermiz
3564 Posts |
Posted - 2005-05-16 : 10:42:21
|
Read my third response...That is still not the best solution, there is some properties I just don't know enough of it to figure it out.I have already done the SQL to retrieve the ID, that is the worst case scenerio, it takes a call to a sproc, and a returned result which is not fast. There is a .net way of doing it but i haven't figured it out yet. Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]Imperfection living for perfection -- [url]http://jhermiz.blogspot.com/[/url] |
 |
|
olay80
Yak Posting Veteran
62 Posts |
Posted - 2005-05-16 : 10:58:23
|
yes i know it's not that good, did u try to load the data u have in a seperate aspx file that would output this data as an xml stream upon calling it from ur main page using java script using DOM object?this means that u have to set and sql in this page bind the data to a DataSet, then DataSet.xmlOutput, and u loop this output using the javascript in ur main calling page...i've done this a while back and it's fast.Oliver |
 |
|
|
|
|
|
|