TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vinod chand
NA
16
10k
datetime formating in datagrid export in txt file in c#
Jun 19 2015 7:59 AM
I am exporting my datagrid field values in txt file through given below code. While exporting its working fine, only in formatting of datetime field, its have some issue.
In the datagrid fields, datetime formatting is "dd/MM/yyyy hh:mm:ss AM/PM", but after exporting in text file, its changed with "dd/MM/yyyy hh:mm:ss". "AM/ PM " value is missing in exported txt file.
Please suggest, how to keep required datagrid datetime format in exported txt file also.
please refer given code which i am using in my export option.
TextWriter sw = new StreamWriter(@"C:\\Export\\Export.txt");
int rowcount = dataGridView1.Rows.Count;
for (int i = 0; i < rowcount - 1; i++)
{
sw.WriteLine(dataGridView1.Rows[i].Cells[0].Value.ToString() + "|"
+ dataGridView1.Rows[i].Cells[1].Value.ToString() + "|"
+ dataGridView1.Rows[i].Cells[2].Value.ToString() + "|"
+ dataGridView1.Rows[i].Cells[3].Value.ToString() + "|"
+ dataGridView1.Rows[i].Cells[4].Value.ToString() + "|");
}
sw.Close();
MessageBox.Show("Data Exported Sucessfully");
Reply
Answers (
2
)
How To Give Page No After Print In Asp.Net C#
How can i set panel control inside