在DataGrid的BoundColumns中格式化数据 [英] Format Data in BoundColumns of DataGrid

查看:82
本文介绍了在DataGrid的BoundColumns中格式化数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想格式化我的DataGrid控件的一些列。

例如,我的DataSet字段之一是DATE字段,在BD中他很好,但是当我在数据网格中向他展示时,他也会花上几个小时。我不想那样。


第二个例子:

BD中的字段:

DtSegm

17-02-2004

注意:当我保存到DB时格式化日期如上所示


在DataGrid中显示如下:

DtSegm

17-02-2004 10:30:45


如何更改。

- -


感谢'(如果你试图帮助我)

希望这对你有帮助(如果我试着帮助你的话)

ruca

Hi

I want to format some columns of my DataGrid control.
Example, one of my fields of DataSet is a DATE field and in BD he is Ok, but
when I show him in datagrid he comes with hours too. I don′t want that.

2nd Example:
Field in BD:
DtSegm
17-02-2004
Note: When I save to DB I format Date to put like above

In DataGrid shows like this:
DtSegm
17-02-2004 10:30:45

How can I change that.
--

Thank''s (if you try to help me)
Hope this help you (if I try to help you)
ruca

推荐答案

如果您使用简单的绑定列(使用属性构建器),您可以

asign属性构建器中的数据格式框,或者在HTML视图中手动分配

DataFormatString属性


如果是模板化列,则可以将格式添加为第三个参数为

Eval函数,如:


DataBinder.Eval(Container,DataItem.DueDate"," d)


问候

何塞。


" ruca" < RU *** @ iol.pt> escribióenel mensaje

news:eo ************** @ TK2MSFTNGP09.phx.gbl ...
If you are using simple bound columns (using the Property builder) you may
asign the Data Format box in the property builder, or manually assign a
DataFormatString attribute in HTML view

If its a templated column, you may add the format as the third argument to
the Eval function, as in:

DataBinder.Eval(Container, "DataItem.DueDate", "d")

Regards
Jose.

"ruca" <ru***@iol.pt> escribió en el mensaje
news:eo**************@TK2MSFTNGP09.phx.gbl...

我想格式化我的DataGrid控件的一些列。
例如,我的DataSet字段之一是DATE字段,在BD中他是好的,
但是当我在datagrid中显示它时他也来了几个小时。我不想那样。

第二个例子:
BD中的字段:
DtSegm
17-02-2004
注意:当我保存到DB I格式日期如上所示

在DataGrid中显示如下:
DtSegm
17-02-2004 10:30:45

如何我可以改变吗。

-

感谢'(如果你试图帮助我)
希望这对你有所帮助(如果我试着帮助你的话) )
ruca
Hi

I want to format some columns of my DataGrid control.
Example, one of my fields of DataSet is a DATE field and in BD he is Ok, but when I show him in datagrid he comes with hours too. I don′t want that.

2nd Example:
Field in BD:
DtSegm
17-02-2004
Note: When I save to DB I format Date to put like above

In DataGrid shows like this:
DtSegm
17-02-2004 10:30:45

How can I change that.
--

Thank''s (if you try to help me)
Hope this help you (if I try to help you)
ruca



ruca,


你可以通过适当地设置

BoundColumn的DataFormatString属性:

http://msdn.microsoft.com/library/en...tringtopic.asp


将其设置为dd-MM-yyyy。请参阅以下链接以获取更多有效的自定义

DateTime格式字符串:

http://msdn.microsoft.com/library/en...matstrings.asp


问候

马丁

" ruca" < RU *** @ iol.pt>在留言中写道

新闻:eo ************** @ TK2MSFTNGP09.phx.gbl ...
Hi, ruca,

You can achive this by setting the DataFormatString property of the
BoundColumn approprietly:

http://msdn.microsoft.com/library/en...tringtopic.asp

Set it to "dd-MM-yyyy". See the following link for more valid custom
DateTime format strings:

http://msdn.microsoft.com/library/en...matstrings.asp

Greetings
Martin
"ruca" <ru***@iol.pt> wrote in message
news:eo**************@TK2MSFTNGP09.phx.gbl...


我想格式化我的DataGrid控件的一些列。
例如,我的一个DataSet字段是DATE字段,而在BD中他是好的,
但是当我在datagrid中显示他时也有几个小时。我不想那样。

第二个例子:
BD中的字段:
DtSegm
17-02-2004
注意:当我保存到DB I格式日期如上所示

在DataGrid中显示如下:
DtSegm
17-02-2004 10:30:45

如何我可以改变吗。

-

感谢'(如果你试图帮助我)
希望这对你有所帮助(如果我试着帮助你的话) )
ruca
Hi

I want to format some columns of my DataGrid control.
Example, one of my fields of DataSet is a DATE field and in BD he is Ok, but when I show him in datagrid he comes with hours too. I don′t want that.

2nd Example:
Field in BD:
DtSegm
17-02-2004
Note: When I save to DB I format Date to put like above

In DataGrid shows like this:
DtSegm
17-02-2004 10:30:45

How can I change that.
--

Thank''s (if you try to help me)
Hope this help you (if I try to help you)
ruca



这有什么问题:


< ; asp:BoundColumn DataField =" DtSgm"只读= QUOT;真"的HeaderText = QUOT; DtSegmento"

DataFormatString = QUOT; DtSgm.ToString( '' DD-MM-YYYY '')">< / ASP:绑定列>


" Martin Dechev" <德******* @ hotmail.com> escreveu na mensagem

新闻:Op ************** @ TK2MSFTNGP11.phx.gbl ...
What''s wrong with this:

<asp:BoundColumn DataField="DtSgm" ReadOnly="True" HeaderText="DtSegmento"
DataFormatString="DtSgm.ToString(''dd-MM-YYYY'')"></asp:BoundColumn>

"Martin Dechev" <de*******@hotmail.com> escreveu na mensagem
news:Op**************@TK2MSFTNGP11.phx.gbl...
ruca,<你可以通过设置
BoundColumn的DataFormatString属性来实现这个目的:

http://msdn.microsoft.com/library/en...webuiwebcontro

lsboundcolumnclassdataformatstringtopic.asp
将其设置为dd-MM-yyyy。请参阅以下链接以获取更有效的自定义
DateTime格式字符串:

http://msdn.microsoft.com/library/en...omdatetimeform

atstrings.asp
问候<马丁
ruca < RU *** @ iol.pt>在消息中写道
新闻:eo ************** @ TK2MSFTNGP09.phx.gbl ...
Hi, ruca,

You can achive this by setting the DataFormatString property of the
BoundColumn approprietly:

http://msdn.microsoft.com/library/en...webuiwebcontro
lsboundcolumnclassdataformatstringtopic.asp
Set it to "dd-MM-yyyy". See the following link for more valid custom
DateTime format strings:

http://msdn.microsoft.com/library/en...omdatetimeform
atstrings.asp
Greetings
Martin
"ruca" <ru***@iol.pt> wrote in message
news:eo**************@TK2MSFTNGP09.phx.gbl...


我想格式化我的DataGrid控件的一些列。
例如,我的DataSet字段之一是DATE字段,在BD中他是好的,
Hi

I want to format some columns of my DataGrid control.
Example, one of my fields of DataSet is a DATE field and in BD he is Ok,


但是

当我在datagrid中向他展示时,他也会花费数小时。我不想那样。

第二个例子:
BD中的字段:
DtSegm
17-02-2004
注意:当我保存到DB I格式日期如上所示

在DataGrid中显示如下:
DtSegm
17-02-2004 10:30:45

如何我可以改变吗。

-

感谢'(如果你试图帮助我)
希望这对你有所帮助(如果我试着帮助你的话) )
ruca
when I show him in datagrid he comes with hours too. I don′t want that.

2nd Example:
Field in BD:
DtSegm
17-02-2004
Note: When I save to DB I format Date to put like above

In DataGrid shows like this:
DtSegm
17-02-2004 10:30:45

How can I change that.
--

Thank''s (if you try to help me)
Hope this help you (if I try to help you)
ruca




这篇关于在DataGrid的BoundColumns中格式化数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆