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

Re: Format Data in BoundColumns of DataGrid by Jose

Jose
Fri Feb 20 07:35:10 CST 2004

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" <ruuca@iol.pt> escribió en el mensaje
news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> 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
>
>



Re: Format Data in BoundColumns of DataGrid by Martin

Martin
Fri Feb 20 07:40:34 CST 2004

Hi, ruca,

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

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsboundcolumnclassdataformatstringtopic.asp

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

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcustomdatetimeformatstrings.asp

Greetings
Martin
"ruca" <ruuca@iol.pt> wrote in message
news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> 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
>
>



Re: Format Data in BoundColumns of DataGrid by ruca

ruca
Fri Feb 20 09:27:02 CST 2004

What's wrong with this:

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



"Martin Dechev" <detcheff_@hotmail.com> escreveu na mensagem
news:Op8$cc79DHA.2404@TK2MSFTNGP11.phx.gbl...
> Hi, ruca,
>
> You can achive this by setting the DataFormatString property of the
> BoundColumn approprietly:
>
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
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-us/cpguide/html/cpconcustomdatetimeform
atstrings.asp
>
> Greetings
> Martin
> "ruca" <ruuca@iol.pt> wrote in message
> news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> > 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
> >
> >
>
>



Re: Format Data in BoundColumns of DataGrid by Martin

Martin
Fri Feb 20 09:35:59 CST 2004

Hi, ruca,

You haven't read the article for the DataFormatString property, have you?

<asp:BoundColumn DataField="DtSgm" ReadOnly="True" HeaderText="DtSegmento"
DataFormatString="dd-MM-yyyy"/>

Greetings
Martin
"ruca" <ruuca@iol.pt> wrote in message
news:ePIt5V89DHA.4020@TK2MSFTNGP09.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" <detcheff_@hotmail.com> escreveu na mensagem
> news:Op8$cc79DHA.2404@TK2MSFTNGP11.phx.gbl...
> > Hi, ruca,
> >
> > You can achive this by setting the DataFormatString property of the
> > BoundColumn approprietly:
> >
> >
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
> 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-us/cpguide/html/cpconcustomdatetimeform
> atstrings.asp
> >
> > Greetings
> > Martin
> > "ruca" <ruuca@iol.pt> wrote in message
> > news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> > > 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
> > >
> > >
> >
> >
>
>



Re: Format Data in BoundColumns of DataGrid by ruca

ruca
Fri Feb 20 09:58:00 CST 2004

How can I format a Field that I have to calculate something.
Like this:
Field1 in DB is a Double
Field1 = 0.11

And I want to appear: 0.11 * 100 = 11


Thanks

"Martin Dechev" <detcheff_@hotmail.com> escreveu na mensagem
news:Op8$cc79DHA.2404@TK2MSFTNGP11.phx.gbl...
> Hi, ruca,
>
> You can achive this by setting the DataFormatString property of the
> BoundColumn approprietly:
>
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
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-us/cpguide/html/cpconcustomdatetimeform
atstrings.asp
>
> Greetings
> Martin
> "ruca" <ruuca@iol.pt> wrote in message
> news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> > 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
> >
> >
>
>



Re: Format Data in BoundColumns of DataGrid by ruca

ruca
Fri Feb 20 10:00:22 CST 2004

I've got working now. I already understand how can I format string's in the
way that I want. Thank's Martin.

But now I have another question:

How can I format a Field that I have to calculate something.
Like this:
Field1 in DB is a Double
Field1 = 0.11

And I want to appear: 0.11 * 100 = 11


Thanks



"Martin Dechev" <detcheff_@hotmail.com> escreveu na mensagem
news:#yCI9c89DHA.1768@TK2MSFTNGP09.phx.gbl...
> Hi, ruca,
>
> You haven't read the article for the DataFormatString property, have you?
>
> <asp:BoundColumn DataField="DtSgm" ReadOnly="True" HeaderText="DtSegmento"
> DataFormatString="dd-MM-yyyy"/>
>
> Greetings
> Martin
> "ruca" <ruuca@iol.pt> wrote in message
> news:ePIt5V89DHA.4020@TK2MSFTNGP09.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" <detcheff_@hotmail.com> escreveu na mensagem
> > news:Op8$cc79DHA.2404@TK2MSFTNGP11.phx.gbl...
> > > Hi, ruca,
> > >
> > > You can achive this by setting the DataFormatString property of the
> > > BoundColumn approprietly:
> > >
> > >
> >
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
> > 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-us/cpguide/html/cpconcustomdatetimeform
> > atstrings.asp
> > >
> > > Greetings
> > > Martin
> > > "ruca" <ruuca@iol.pt> wrote in message
> > > news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> > > > 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
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: Format Data in BoundColumns of DataGrid by Martin

Martin
Fri Feb 20 09:56:22 CST 2004


It should be "{0:dd-MM-yyyy}" in this case, sorry for the mistake.

Hope this helps
Martin

"Martin Dechev" <detcheff_@hotmail.com> wrote in message
news:#yCI9c89DHA.1768@TK2MSFTNGP09.phx.gbl...
> Hi, ruca,
>
> You haven't read the article for the DataFormatString property, have you?
>
> <asp:BoundColumn DataField="DtSgm" ReadOnly="True" HeaderText="DtSegmento"
> DataFormatString="dd-MM-yyyy"/>
>
> Greetings
> Martin
> "ruca" <ruuca@iol.pt> wrote in message
> news:ePIt5V89DHA.4020@TK2MSFTNGP09.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" <detcheff_@hotmail.com> escreveu na mensagem
> > news:Op8$cc79DHA.2404@TK2MSFTNGP11.phx.gbl...
> > > Hi, ruca,
> > >
> > > You can achive this by setting the DataFormatString property of the
> > > BoundColumn approprietly:
> > >
> > >
> >
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
> > 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-us/cpguide/html/cpconcustomdatetimeform
> > atstrings.asp
> > >
> > > Greetings
> > > Martin
> > > "ruca" <ruuca@iol.pt> wrote in message
> > > news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> > > > 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
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: Format Data in BoundColumns of DataGrid by Jose

Jose
Fri Feb 20 11:34:33 CST 2004

1. In the grid's Property Builder page, clear the "Data Format" field and
then convert your "bound column" into a "templated column" using the
provided link

2. Edit the HTML and replace the binding expression as follows (assuming
DataItem.Qty is an integer)

Instead of
<%# DataBinder.Eval(Container, "DataItem.Qty") %>
use
<%# (((int)DataBinder.Eval(Container,
"DataItem.Qty"))*100).ToString("d9") %>

Regards
Jose.

"ruca" <ruuca@iol.pt> escribió en el mensaje
news:O8gyMn89DHA.1312@TK2MSFTNGP09.phx.gbl...
> How can I format a Field that I have to calculate something.
> Like this:
> Field1 in DB is a Double
> Field1 = 0.11
>
> And I want to appear: 0.11 * 100 = 11
>
>
> Thanks
>
> "Martin Dechev" <detcheff_@hotmail.com> escreveu na mensagem
> news:Op8$cc79DHA.2404@TK2MSFTNGP11.phx.gbl...
> > Hi, ruca,
> >
> > You can achive this by setting the DataFormatString property of the
> > BoundColumn approprietly:
> >
> >
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
> 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-us/cpguide/html/cpconcustomdatetimeform
> atstrings.asp
> >
> > Greetings
> > Martin
> > "ruca" <ruuca@iol.pt> wrote in message
> > news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> > > 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
> > >
> > >
> >
> >
>
>



Re: Format Data in BoundColumns of DataGrid by ruca

ruca
Fri Feb 20 12:34:22 CST 2004

<%# (((int)DataBinder.Eval(Container,"DataItem.Qty"))*100).ToString("d9") %>

The part of ToString("d9") doesn't work.
I have to set this value: DataBinder.Eval(Container,"DataItem.Qty"))*100)
into a double of 2 decimal places

How?



"Jose Marcenaro" <josem@nospam.da-vinci.com.ar> escreveu na mensagem
news:OPyeef99DHA.1312@TK2MSFTNGP09.phx.gbl...
> 1. In the grid's Property Builder page, clear the "Data Format" field and
> then convert your "bound column" into a "templated column" using the
> provided link
>
> 2. Edit the HTML and replace the binding expression as follows (assuming
> DataItem.Qty is an integer)
>
> Instead of
> <%# DataBinder.Eval(Container, "DataItem.Qty") %>
> use
> <%# (((int)DataBinder.Eval(Container,
> "DataItem.Qty"))*100).ToString("d9") %>
>
> Regards
> Jose.
>
> "ruca" <ruuca@iol.pt> escribió en el mensaje
> news:O8gyMn89DHA.1312@TK2MSFTNGP09.phx.gbl...
> > How can I format a Field that I have to calculate something.
> > Like this:
> > Field1 in DB is a Double
> > Field1 = 0.11
> >
> > And I want to appear: 0.11 * 100 = 11
> >
> >
> > Thanks
> >
> > "Martin Dechev" <detcheff_@hotmail.com> escreveu na mensagem
> > news:Op8$cc79DHA.2404@TK2MSFTNGP11.phx.gbl...
> > > Hi, ruca,
> > >
> > > You can achive this by setting the DataFormatString property of the
> > > BoundColumn approprietly:
> > >
> > >
> >
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
> > 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-us/cpguide/html/cpconcustomdatetimeform
> > atstrings.asp
> > >
> > > Greetings
> > > Martin
> > > "ruca" <ruuca@iol.pt> wrote in message
> > > news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> > > > 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
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: Format Data in BoundColumns of DataGrid by Jose

Jose
Mon Feb 23 05:47:51 CST 2004

Use either .ToString("#.00")
or .ToString("#,###.00") if you want thousands separators

"ruca" <ruuca@iol.pt> escribió en el mensaje
news:eJoSl%2399DHA.2404@TK2MSFTNGP12.phx.gbl...
> <%# (((int)DataBinder.Eval(Container,"DataItem.Qty"))*100).ToString("d9")
%>
>
> The part of ToString("d9") doesn't work.
> I have to set this value: DataBinder.Eval(Container,"DataItem.Qty"))*100)
> into a double of 2 decimal places
>
> How?
>
>
>
> "Jose Marcenaro" <josem@nospam.da-vinci.com.ar> escreveu na mensagem
> news:OPyeef99DHA.1312@TK2MSFTNGP09.phx.gbl...
> > 1. In the grid's Property Builder page, clear the "Data Format" field
and
> > then convert your "bound column" into a "templated column" using the
> > provided link
> >
> > 2. Edit the HTML and replace the binding expression as follows (assuming
> > DataItem.Qty is an integer)
> >
> > Instead of
> > <%# DataBinder.Eval(Container, "DataItem.Qty") %>
> > use
> > <%# (((int)DataBinder.Eval(Container,
> > "DataItem.Qty"))*100).ToString("d9") %>
> >
> > Regards
> > Jose.
> >
> > "ruca" <ruuca@iol.pt> escribió en el mensaje
> > news:O8gyMn89DHA.1312@TK2MSFTNGP09.phx.gbl...
> > > How can I format a Field that I have to calculate something.
> > > Like this:
> > > Field1 in DB is a Double
> > > Field1 = 0.11
> > >
> > > And I want to appear: 0.11 * 100 = 11
> > >
> > >
> > > Thanks
> > >
> > > "Martin Dechev" <detcheff_@hotmail.com> escreveu na mensagem
> > > news:Op8$cc79DHA.2404@TK2MSFTNGP11.phx.gbl...
> > > > Hi, ruca,
> > > >
> > > > You can achive this by setting the DataFormatString property of the
> > > > BoundColumn approprietly:
> > > >
> > > >
> > >
> >
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
> > > 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-us/cpguide/html/cpconcustomdatetimeform
> > > atstrings.asp
> > > >
> > > > Greetings
> > > > Martin
> > > > "ruca" <ruuca@iol.pt> wrote in message
> > > > news:eoMY1G79DHA.4020@TK2MSFTNGP09.phx.gbl...
> > > > > 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
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>