Home All Groups Group Topic Archive Search About

DropDownList: Accesing the columns values

Author
3 Oct 2007 11:27 PM
WhiskeyRomeo
I have a ddl bound to a sqldatasource which returns 4 columns.  It is easy to
access two of them since one serves as the datavaluefield and the other as
the datatextfield.  But how do I access the other columns' values in the
selecteditem of the ddl?

I was expecting to see something like this:

ddl1.selecteditem.columns("whatevercolumnIwant").value  but, of course, that
does not exist.

Any help is appreciated.

WR

Author
4 Oct 2007 2:09 PM
David R. Longnecker
WR-

Unless you extend the DropDownList control and add a bit more functionality,
they only take two columns (a key/value pair) of information--one that is
associated to the textual display and one behind the scenes for the value.
When the HTML is generated, the KV pair is translated into:

<option value="__yourValueParameter__">__yourTextFieldParameter__</option>

How are you wanting to use your other two columns?  Append them as potential
ListItems in the DropDownList control?  If you could post an example of your
code, that'd be helpful.

-dl

--
David R. Longnecker
http://blog.tiredstudent.com

Show quote
> I have a ddl bound to a sqldatasource which returns 4 columns.  It is
> easy to access two of them since one serves as the datavaluefield and
> the other as the datatextfield.  But how do I access the other
> columns' values in the selecteditem of the ddl?
>
> I was expecting to see something like this:
>
> ddl1.selecteditem.columns("whatevercolumnIwant").value  but, of
> course, that does not exist.
>
> Any help is appreciated.
>
> WR
>
Author
4 Oct 2007 2:48 PM
WhiskeyRomeo
David,

Thank you for the reply.

The dropdown list is actually a list of available appointments retrieved via
a stored procedure:

SELECT Cast(Cast(DayDT as Varchar(11)) + ' ' + StartTime12 AS DateTime) AS
APPT, DayDT, StartTime24, StartTime12
FROM tblOrgTimeSlot
WHERE (Org_ID = @Org_ID)AND(Taken < Capacity)
ORDER BY DayDT, StartTime24

So APPT is the  datavaluefield and datatextfield.  So an item looks like

9/30/2007  9:00 AM, 9/25/2007, 0900, 8:00 AM

The customer only sees first column and the first column is what makes each
item unique.  But rather than string manipulate the Appt back into it parts I
just want the StartTime24 and DayDT value. 

I can do this via a Infragistic combobox or I can use a dataset as the
dataource.  I was just hoping I could do this using the MS standard ddl.

Bill

Show quote
"David R. Longnecker" wrote:

> WR-
>
> Unless you extend the DropDownList control and add a bit more functionality,
> they only take two columns (a key/value pair) of information--one that is
> associated to the textual display and one behind the scenes for the value.
>  When the HTML is generated, the KV pair is translated into:
>
> <option value="__yourValueParameter__">__yourTextFieldParameter__</option>
>
> How are you wanting to use your other two columns?  Append them as potential
> ListItems in the DropDownList control?  If you could post an example of your
> code, that'd be helpful.
>
> -dl
>
> --
> David R. Longnecker
> http://blog.tiredstudent.com
>
> > I have a ddl bound to a sqldatasource which returns 4 columns.  It is
> > easy to access two of them since one serves as the datavaluefield and
> > the other as the datatextfield.  But how do I access the other
> > columns' values in the selecteditem of the ddl?
> >
> > I was expecting to see something like this:
> >
> > ddl1.selecteditem.columns("whatevercolumnIwant").value  but, of
> > course, that does not exist.
> >
> > Any help is appreciated.
> >
> > WR
> >
>
>
>

AddThis Social Bookmark Button