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
Akhter HUssain
720
1.3k
102.2k
How to Retrieve null datetime in a texbox from gridview ?
Sep 11 2019 3:43 AM
i am selection row from gridview in which leftdate is not available/empty ,so when i select that row editing then exception is raised that
(String was not recognized as a valid DateTime.')
here is screen shot
here c# code
protected
void
Edit(
object
sender, EventArgs e)
{
using
(GridViewRow row = (GridViewRow)((LinkButton)sender).Parent.Parent)
{
txtEmpID.ReadOnly =
true
;
txtEmpID.Text = row.Cells[0].Text;
txtEmpName.Text = row.Cells[1].Text;
txtFahterName.Text = row.Cells[2].Text;
//ddlSecID.ClearSelection();
//ddlSecID.Items.FindByText(row.Cells[3].Text).Selected = true;
//txtjdate.Text = row.Cells[4].Text;
txtCNIC.Text = row.Cells[3].Text;
ddlSecID.ClearSelection();
if
(ddlSecID.Items.FindByText(row.Cells[4].Text) !=
null
)
{
ddlSecID.Items.FindByText(row.Cells[4].Text).Selected =
true
;
}
if
(ddlstatus.Items.FindByText(row.Cells[5].Text) !=
null
)
{
ddlstatus.Items.FindByText(row.Cells[5].Text).Selected =
true
;
}
txtjdate.Text = Convert.ToDateTime(row.Cells[6].Text).ToString(
"dd/MM/yyyy"
);
if
(!
string
.IsNullOrEmpty(txtldate.Text))
{
// DateTime date = DateTime.Parse(txtldate.Text);
txtldate.Text =
null
;
}
else
{
txtldate.Text = Convert.ToDateTime(row.Cells[7].Text).ToString(
"dd/MM/yyyy"
);
}
popup.Show();
}
}
Reply
Answers (
26
)
How to get months difference between two dates in c#
i want to divide a square field into grids