Click here to Skip to main content
15,895,772 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this works in vb.net datagridview .Columns[0].DefaultCellStyle.Format = "yy/mm/dd";
but in asp.net there is no "DefaultCellStyle" so how do i do this.
Posted

e.g. 1:
<asp:boundfield datafield="RequestDate" headertext="Date" htmlencode="false" xmlns:asp="#unknown">
DataFormatString="{0:dd-MMM-yyyy}" />

e.g. 2:

<asp:Label ID="LabelDt" runat="server" Text='<%# Bind("Date_Of_Apply","{0:dd/MM/yyyy}") %>'>

e.g. 3:
Text='<%# !String.IsNullOrEmpty(Eval("DateOfEffect").ToString()) ?Convert.ToDateTime(Eval("DateOfEffect")).ToString("dd-MMM-yyyy") : "" %>'
 
Share this answer
 
v2
Comments
wizy@2020 20-Oct-12 7:55am    
this is my code
sqlSTRGRID = "SELECT DATEPAID, AMOUNTPAID FROM tblPaymentDetails INNER JOIN tblCustomers ON tblCustomers.CUSTNEWID=tblPaymentDetails.CUSTOMERID WHERE DATEPAID >= '" & DFrom & "' AND DATEPAID <= '" & DTo & "' AND tblPaymentDetails.BRANCH = '" & cboBranch.Text & "' AND tblPaymentDetails.CUSTOMERID = '" & customerid & "'"
ExecuteSQLQueryDataGrid(sqlSTRGRID)
If sqlDTGRID.Rows.Count > 0 Then
GridView1.DataSource = sqlDTGRID
GridView1.DataBind()
If GridView1.Rows.Count > 0 Then
GridView1.HeaderRow.Cells(0).Text = "Date"
GridView1.HeaderRow.Cells(1).Text = "Amount GH¢"
End If
End If
and i want to add some code to format the date field.I dont want the code to be in asp but in vb.net
The Code i Have Provide U Is For .aspx Page Not For .vb Page...

You Should to use It On .aspx Page Control(s), if u are not familiar with my suggestion please write you .aspx code here...
 
Share this answer
 
Comments
wizy@2020 20-Oct-12 8:38am    
can u provide me with code i will use on .vb page?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900