datagrid : change the string formatting expression

F

Franck

hello,

i'm looking for code (C# preferably)
in order to change programmatically in a datagrid
the string formatting expression of one bound colum

thank you
 
E

Emil Christopher Melar

Franck said:
hello,

i'm looking for code (C# preferably)
in order to change programmatically in a datagrid
the string formatting expression of one bound colum

thank you

Example:

<%# DataBinder.Eval(Container.DataItem, "MyDate", "{0:d}")%>

Will format the DateTime to display as short-date, ie dd.mm.yyyy or
other format based on the culture.

The third parameter is the format expression.

Go read MSDN.
 
E

Emil Christopher Melar

Franck said:
hello,

i'm looking for code (C# preferably)
in order to change programmatically in a datagrid
the string formatting expression of one bound colum

thank you

Sorry, Ignore my last post, I didn't read your post well enough.

Again, sorry.
 
E

Emil Christopher Melar

Franck said:
hello,

i'm looking for code (C# preferably)
in order to change programmatically in a datagrid
the string formatting expression of one bound colum

thank you

I do not have enough information.

The only solution that I can think of, is that you have to drop the
aspx-style binding to the column, and rather do this in ItemDataBound by
referencing the datasource from the e.Item.DataItem and reference a
control (literal or whatever) in the ItemTemplate instead.

Where do you want to change the format string, based on what criteria?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top