How can i show DATAGRID date with out any time frame.

  • Thread starter Thread starter karunakar
  • Start date Start date
K

karunakar

Hi All


I was poplating Datagrid
Datagrid has one of the column showing datetime field format iam showing
DATE here not Necessary to populate the Time Frame
Even my datebase column also does'nt have any time frame Query is shoing
only dates;
But ASP.NET dategrid showing Time frame also,
How can remove the time frame in datagrid
<asp:Label ID="lblWorker" Text='<%DataBinder.Eval(Container.DataItem,
"dateissue")%>' Runat=server />
How can i format this Without date
Date base query is showing - DateIssued Column :1997-26-10
But Ineed Only date:
Datagrid showing lik this :
test dateIssued dateIssued dateIssued
1 10/26/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
2 10/25/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
3 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM
4 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM
5 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM
6 10/24/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
7 10/26/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
8 10/25/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
9 11/2/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00 AM
10 11/3/1997 12:00:00 AM 11/3/1997 12:00:00 AM 11/3/1997 12:00:00
AM
test dateIssued dateIssued dateIssued
1 10/26/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
2 10/25/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
3 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM
4 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM
5 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM
6 10/24/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
7 10/26/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
8 10/25/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
9 11/2/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00 AM
10 11/3/1997 12:00:00 AM 11/3/1997 12:00:00 AM 11/3/1997 12:00:00
AM
test dateIssued dateIssued dateIssued
1 10/26/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
2 10/25/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
3 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM
4 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM
5 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM
6 10/24/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
7 10/26/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
8 10/25/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
9 11/2/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00 AM
10 11/3/1997 12:00:00 AM 11/3/1997 12:00:00 AM 11/3/1997 12:00:00
AM

Regards,
Venu
 
Hi,

You have to use the DateTime.ToShortDateString() for this.

Now the tricky thing is that the DataBinder.Eval does only support a
property or field, not a method, so you cannot use it. so you have to
convert Container.DataItem to the correct type , says DataRow and then
convert the column to DateTime and do the calling:

try this:
DataBinder.Eval(Container.DataItem,"dateissue.ToShortDateString() ")%

<%#
((DateTime)((DataRow)Container.DataItem)["RowName"]).ToShortDateString() %>

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
 
Hi All
Iam Binding like this

<asp:TemplateColumn>
<HeaderTemplate>
dateIssued
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="Label2" Text='<%#
((DateTime)((DataRow)Container.DataItem)["datecomplete"]).ToShortDateString(
)%>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn>


Here ["datecomplete"] this is column name
I doing like this.
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'DataRow' could
not be found (are you missing a using directive or an assembly reference?)

It's giving Error like this

Regards
venu

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

You have to use the DateTime.ToShortDateString() for this.

Now the tricky thing is that the DataBinder.Eval does only support a
property or field, not a method, so you cannot use it. so you have to
convert Container.DataItem to the correct type , says DataRow and then
convert the column to DateTime and do the calling:

try this:
DataBinder.Eval(Container.DataItem,"dateissue.ToShortDateString() ")%

<%#
((DateTime)((DataRow)Container.DataItem)["RowName"]).ToShortDateString() %>

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation




karunakar said:
Hi All


I was poplating Datagrid
Datagrid has one of the column showing datetime field format iam showing
DATE here not Necessary to populate the Time Frame
Even my datebase column also does'nt have any time frame Query is shoing
only dates;
But ASP.NET dategrid showing Time frame also,
How can remove the time frame in datagrid
<asp:Label ID="lblWorker" Text='<%DataBinder.Eval(Container.DataItem,
"dateissue")%>' Runat=server />
How can i format this Without date
Date base query is showing - DateIssued Column :1997-26-10
But Ineed Only date:
Datagrid showing lik this :
test dateIssued dateIssued dateIssued
1 10/26/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
2 10/25/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
3 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997
12:00:00
AM
4 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997
12:00:00
AM
5 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997
12:00:00
AM
6 10/24/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
7 10/26/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
8 10/25/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
9 11/2/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997
12:00:00
AM
10 11/3/1997 12:00:00 AM 11/3/1997 12:00:00 AM 11/3/1997 12:00:00
AM
test dateIssued dateIssued dateIssued
1 10/26/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
2 10/25/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
3 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997
12:00:00
AM
4 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997
12:00:00
AM
5 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997
12:00:00
AM
6 10/24/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
7 10/26/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
8 10/25/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
9 11/2/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997
12:00:00
AM
10 11/3/1997 12:00:00 AM 11/3/1997 12:00:00 AM 11/3/1997 12:00:00
AM
test dateIssued dateIssued dateIssued
1 10/26/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
2 10/25/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997 12:00:00
AM
3 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997
12:00:00
AM
4 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997
12:00:00
AM
5 11/1/1997 12:00:00 AM 11/1/1997 12:00:00 AM 11/1/1997
12:00:00
AM
6 10/24/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
7 10/26/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
8 10/25/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997 12:00:00
AM
9 11/2/1997 12:00:00 AM 11/2/1997 12:00:00 AM 11/2/1997
12:00:00
AM
10 11/3/1997 12:00:00 AM 11/3/1997 12:00:00 AM 11/3/1997 12:00:00
AM

Regards,
Venu
 
Hi All
Iam Binding like this

<asp:TemplateColumn>
<HeaderTemplate>
dateIssued
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="Label2" Text='<%#
((DateTime)((DataRow)Container.DataItem)["datecomplete"]).ToShortDateStr
ing()%>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn>


Here ["datecomplete"] this is column name
I doing like this.
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'DataRow'
could not be found (are you missing a using directive or an assembly
reference?)

It's giving Error like this

Regards
venu
 
You have to include the System.Data namespace in the page with this

<% @Import namespace="System.Data" %

Cheers,
 
Back
Top