Answer the question
In order to leave comments, you need to log in
How to fix The conversion of a nvarchar data type to a datetime data type?
Hello.
There are 2 GridViews, when a row is selected in the first, the related data should open in the second.
But when the "select" item is clicked, an exception is thrown:
"Exception details: System.Data.SqlClient.SqlException: The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value."
private void LinesCount()
{
GridView2.DataBind();
int count = GridView2.Rows.Count;
Label1.Text = "Всего строк - " + count.ToString();
if (count == 0)
Button13.Visible = true;
else
Button13.Visible = false;
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
DateChecking();
LinesCount();
}
GridView2.DataBind();
Answer the question
In order to leave comments, you need to log in
The answer turned out to be very simple, I'm sorry)
because. method function DateChecking received the data of the present time. then it was necessary to transform:
DateField.Value = DateTime.Now.ToShortDateString();
const string dateTimePattern = "yyyy.MM.dd";
DateField.Value = DateTime.Now.ToString(dateTimePattern);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question