473,396 Members | 1,833 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,396 software developers and data experts.

DataGrid binding

Hi,

I'm binding a DataRead (obtained from a mssql SP)to a DataGrid, and one
of the values is a date...

The problem is that date is shown as dd/mm/yyyy hh:mm:ss and I would
like to format it as dd/mm/yyyy...

How can I do it ?

I have seen some code using ItemDataBound event, but I can't manage to
apply them...

TIA
Nov 19 '05 #1
5 1163
OK, keep trying to apply ItemDataBound event. What is the problem? To format
date use DateTime.ToString (formatString) method with format string
"dd/mm/yyy".

Eliyahu

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:u4**************@TK2MSFTNGP14.phx.gbl...
Hi,

I'm binding a DataRead (obtained from a mssql SP)to a DataGrid, and one
of the values is a date...

The problem is that date is shown as dd/mm/yyyy hh:mm:ss and I would
like to format it as dd/mm/yyyy...

How can I do it ?

I have seen some code using ItemDataBound event, but I can't manage to
apply them...

TIA

Nov 19 '05 #2
My problem is that I can't find a sample for to retreive cell value and
reasign to it a new value...

Eliyahu Goldin wrote:
OK, keep trying to apply ItemDataBound event. What is the problem? To format
date use DateTime.ToString (formatString) method with format string
"dd/mm/yyy".

Eliyahu

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:u4**************@TK2MSFTNGP14.phx.gbl...
Hi,

I'm binding a DataRead (obtained from a mssql SP)to a DataGrid, and one
of the values is a date...

The problem is that date is shown as dd/mm/yyyy hh:mm:ss and I would
like to format it as dd/mm/yyyy...

How can I do it ?

I have seen some code using ItemDataBound event, but I can't manage to
apply them...

TIA


Nov 19 '05 #3
OK, suppose your column 0 contains the date you want to convert.

private void dgSelection_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
{
return;
}
e.Item.Cells[0].Text =
System.Convert.ToDateTime(e.Item.Cells[0].Text ).ToString("dd/mm/yyyy");
}
Eliyahu

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:Oi**************@TK2MSFTNGP11.phx.gbl...
My problem is that I can't find a sample for to retreive cell value and
reasign to it a new value...

Eliyahu Goldin wrote:
OK, keep trying to apply ItemDataBound event. What is the problem? To format date use DateTime.ToString (formatString) method with format string
"dd/mm/yyy".

Eliyahu

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:u4**************@TK2MSFTNGP14.phx.gbl...
Hi,

I'm binding a DataRead (obtained from a mssql SP)to a DataGrid, and one
of the values is a date...

The problem is that date is shown as dd/mm/yyyy hh:mm:ss and I would
like to format it as dd/mm/yyyy...

How can I do it ?

I have seen some code using ItemDataBound event, but I can't manage to
apply them...

TIA


Nov 19 '05 #4
OK, that's the code I need... This code give me error with datetime
converstion, but that's another story...

Thanx

Eliyahu Goldin wrote:
OK, suppose your column 0 contains the date you want to convert.

private void dgSelection_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
{
return;
}
e.Item.Cells[0].Text =
System.Convert.ToDateTime(e.Item.Cells[0].Text ).ToString("dd/mm/yyyy");
}
Eliyahu

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:Oi**************@TK2MSFTNGP11.phx.gbl...
My problem is that I can't find a sample for to retreive cell value and
reasign to it a new value...

Eliyahu Goldin wrote:

OK, keep trying to apply ItemDataBound event. What is the problem? To
format
date use DateTime.ToString (formatString) method with format string
"dd/mm/yyy".

Eliyahu

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:u4**************@TK2MSFTNGP14.phx.gbl...
Hi,

I'm binding a DataRead (obtained from a mssql SP)to a DataGrid, and one
of the values is a date...

The problem is that date is shown as dd/mm/yyyy hh:mm:ss and I would
like to format it as dd/mm/yyyy...

How can I do it ?

I have seen some code using ItemDataBound event, but I can't manage to
apply them...

TIA


Nov 19 '05 #5
Check out "Formatting Dates, Currency, and Other Data" section in this
article,
http://msdn.microsoft.com/library/de...verControl.asp

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
OK, that's the code I need... This code give me error with datetime
converstion, but that's another story...

Thanx

Eliyahu Goldin wrote:
OK, suppose your column 0 contains the date you want to convert.

private void dgSelection_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
{
return;
}
e.Item.Cells[0].Text =
System.Convert.ToDateTime(e.Item.Cells[0].Text ).ToString("dd/mm/yyyy");
}
Eliyahu

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:Oi**************@TK2MSFTNGP11.phx.gbl...
My problem is that I can't find a sample for to retreive cell value and
reasign to it a new value...

Eliyahu Goldin wrote:
OK, keep trying to apply ItemDataBound event. What is the problem? To


format
date use DateTime.ToString (formatString) method with format string
"dd/mm/yyy".

Eliyahu

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:u4**************@TK2MSFTNGP14.phx.gbl...
>Hi,
>
>I'm binding a DataRead (obtained from a mssql SP)to a DataGrid, and one>of the values is a date...
>
>The problem is that date is shown as dd/mm/yyyy hh:mm:ss and I would
>like to format it as dd/mm/yyyy...
>
>How can I do it ?
>
>I have seen some code using ItemDataBound event, but I can't manage to
>apply them...
>
>TIA


Nov 19 '05 #6

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

Similar topics

6
by: Shivang | last post by:
Hello Everybody, I am using Datagrid in VB.net. I don't want the auto generation of rows in the datagrid (last row shouldnt be the new row with empty values)..in addition to this the datagrid...
0
by: Tom Hughes | last post by:
I want to change one field of all selected rows to a provided value. Problem 1 I am using the Binding Manager Base to bind the datagrid to the appropriate dataTable as recommended by KB817247....
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
4
by: Steve B. | last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's reflect the contents of the grid cells. Sorting of columns (both thru VS and programmatically) work fine except, when the...
0
by: Dave | last post by:
Tried posting in the Winform Forum without much luck, so posting here... After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is...
6
by: Alpha | last post by:
I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on...
3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
5
by: Brad Shook | last post by:
I am trying to bind one column of a datagrid to a seperate textbox and the rest of the fields to a datagrid. the comments are too large to fit in a datagrid so I created a textbox below the...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.