How to show date from mysql in asp.net c#

Posted by Shubham under ASP.NET on 1/1/2013 | Points: 10 | Views : 2591 | Status : [Member] | Replies : 4
hi!!!!!
i m working on a project which have asp.net is front end and mysql is backend
but when i m fatching date from database on gridview date is not shown
and i m using gridview datsource and bindind the grid from code behind
plzz dont ask me to use boundfield

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar



Responses

Posted by: Saratvaddilli on: 1/1/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Put auto generation ="False'

 if (e.Row.RowType == DataControlRowType.DataRow)

{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
DateTime dateString = DateTime.Parse(e.Row.Cells[2].Text, null);
e.Row.Cells[2].Text = string.Format("{0:dd MMM yyyy HH:mm}", dateString);
}
}


where 2 is the column date

once check this link
http://forums.asp.net/t/1647887.aspx/1

Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 1/2/2013 [Member] Bronze | Points: 25

Up
0
Down
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:TextBox ID="txtReq" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem,"date")).ToString("dd/MM/yyyy") %>' Width="70"></asp:TextBox>
<cc1:CalendarExtender ID="cc1" Format="dd/MM/yyyy" PopupButtonID="txtReq" runat="server" TargetControlID="txtReq" />
</ItemTemplate>
</asp:TemplateField>

Thanks
Pavan Kumar
Mark Answer if this fits the need

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shubham on: 1/2/2013 [Member] Starter | Points: 25

Up
0
Down
V.SaratChand
where can i put this function or which event because i need converted date on gridview binding time

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saratvaddilli on: 1/2/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
we can use the above to get the value of date column form db and convert into datetime

Can you once please ask your requirement once again in detail or post some piece of code

Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response