Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to format "Drop Down List" TextFields and ValueFields?

Reply
Thread Tools

How to format "Drop Down List" TextFields and ValueFields?

 
 
=?Utf-8?B?Y2hhcmxpZXdlc3Q=?=
Guest
Posts: n/a
 
      07-04-2005
Hello -

I've binded a dataset to a Drop Down List control on my web form, using C#,
however, the DateTime value is printed in long format. For example:
04/07/2006 12:00 AM.

My code is:

ddlObs.DataSource = ds.Tables["Observations"].DefaultView;
ddlObs.DataTextField = "ObsDate";
ddlObs.DataValueField = "ObsDate";

How can I use the ddlObs.DataTextFormatString property so that the TextField
value is only "04/07/2005"?

Thanks,
 
Reply With Quote
 
 
 
 
Lars Netzel
Guest
Posts: n/a
 
      07-04-2005
Check the:
DataTextFormatString() Property on DropDownLists

/Lars

"charliewest" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello -
>
> I've binded a dataset to a Drop Down List control on my web form, using
> C#,
> however, the DateTime value is printed in long format. For example:
> 04/07/2006 12:00 AM.
>
> My code is:
>
> ddlObs.DataSource = ds.Tables["Observations"].DefaultView;
> ddlObs.DataTextField = "ObsDate";
> ddlObs.DataValueField = "ObsDate";
>
> How can I use the ddlObs.DataTextFormatString property so that the
> TextField
> value is only "04/07/2005"?
>
> Thanks,



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Y2hhcmxpZXdlc3Q=?=
Guest
Posts: n/a
 
      07-04-2005
Lars,

this feedback is really *not* helpful, as the source you reference is quite
obvious. I do read the manual before posting. if you would read the
documentation yourself, the information only refers to numeric values.

"Lars Netzel" wrote:

> Check the:
> DataTextFormatString() Property on DropDownLists
>
> /Lars
>
> "charliewest" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello -
> >
> > I've binded a dataset to a Drop Down List control on my web form, using
> > C#,
> > however, the DateTime value is printed in long format. For example:
> > 04/07/2006 12:00 AM.
> >
> > My code is:
> >
> > ddlObs.DataSource = ds.Tables["Observations"].DefaultView;
> > ddlObs.DataTextField = "ObsDate";
> > ddlObs.DataValueField = "ObsDate";
> >
> > How can I use the ddlObs.DataTextFormatString property so that the
> > TextField
> > value is only "04/07/2005"?
> >
> > Thanks,

>
>
>

 
Reply With Quote
 
=?Utf-8?B?Y2hhcmxpZXdlc3Q=?=
Guest
Posts: n/a
 
      07-04-2005
Thanks! This is somewhat of a workaround, but it works nicely!

"Eliyahu Goldin" wrote:

> Handle PreRender event. In the event handler loop through the ddl's items
> and format values programmatically.
>
> Eliyahu
>
> "charliewest" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello -
> >
> > I've binded a dataset to a Drop Down List control on my web form, using

> C#,
> > however, the DateTime value is printed in long format. For example:
> > 04/07/2006 12:00 AM.
> >
> > My code is:
> >
> > ddlObs.DataSource = ds.Tables["Observations"].DefaultView;
> > ddlObs.DataTextField = "ObsDate";
> > ddlObs.DataValueField = "ObsDate";
> >
> > How can I use the ddlObs.DataTextFormatString property so that the

> TextField
> > value is only "04/07/2005"?
> >
> > Thanks,

>
>
>

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-04-2005
Handle PreRender event. In the event handler loop through the ddl's items
and format values programmatically.

Eliyahu

"charliewest" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello -
>
> I've binded a dataset to a Drop Down List control on my web form, using

C#,
> however, the DateTime value is printed in long format. For example:
> 04/07/2006 12:00 AM.
>
> My code is:
>
> ddlObs.DataSource = ds.Tables["Observations"].DefaultView;
> ddlObs.DataTextField = "ObsDate";
> ddlObs.DataValueField = "ObsDate";
>
> How can I use the ddlObs.DataTextFormatString property so that the

TextField
> value is only "04/07/2005"?
>
> Thanks,



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dealing with spaces in textfields. lrantisi Java 2 11-26-2006 03:44 PM
Validate undefined number of checkboxes and textfields JAPIO Javascript 3 11-18-2005 08:01 AM
How to layout textfields and keep size at 1 character height Jim Java 1 04-10-2004 07:08 PM
accessing textfields J. Albers Java 5 01-20-2004 08:57 AM
how to keep state of checkboxes and textfields SteKel2002 HTML 0 12-21-2003 02:10 PM



Advertisments