473,320 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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,
Nov 19 '05 #1
4 9384
Check the:
DataTextFormatString() Property on DropDownLists

/Lars

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
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,

Nov 19 '05 #2
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" <ch*********@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
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,


Nov 19 '05 #3
Handle PreRender event. In the event handler loop through the ddl's items
and format values programmatically.

Eliyahu

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
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,

Nov 19 '05 #4
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" <ch*********@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
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,


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Larry R Harrison Jr | last post by:
I am looking for javascript and a basic tutorial on how to make mouse-over drop-down menus--the type that when you "hover" over a subject links relevant to that subject "emerge" which you can then...
4
by: Larry R Harrison Jr | last post by:
I have them working now, courtesy of the link given in the prior thread--the HVMenu over at Dynamic Drive myself. http://www.dynamicdrive.com I have them working as side-bar menus, not...
1
by: John | last post by:
Hi everyone. I'm having a real problem with a drop-down menu that I'm using. Simply, as I scroll down the page, it follows me. I don't want this!! I guess it's all my fault for using...
2
by: Kyle Blaney | last post by:
I am using a Listbox and can not get the "drop down" effect. My listbox is populated with 20 items and a vertical scrollbar is automatically added. One item is visible. When I click on the...
0
by: Alan | last post by:
I 'm new for .NET, and actually on my own to develop my employer's web application. I can't bind my dropDownList control to entries in the database. Here is a code:...
4
by: charliewest | last post by:
I need to set the selected drop down list value at run time. I am aware of the method "SelectIndex" however this works only if you know the precise location of the value within the ListItem...
2
by: Doogly | last post by:
Hello everyone, I'm really new to Javascript and was wondering if anyone could give me code for a nice looking drop down menu. Ideally it would do that little scrolly animation thingy when it...
1
missshaikh
by: missshaikh | last post by:
Hi All Friends. I need your help.. I want to format Bold Italic in Drop Down List Control in C#.i retrieve my data from db. like this . ________________ CD ROOM
2
by: Doug | last post by:
Hi, I can't figure out how to create a drop-down list box. The help file says it exists. The icon in the help file matches the combobox in the toolbox. I tried using a combox box, both with and...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.