Hi
I am geeting above error on below line. In ltrlSessionDate.Text value is "21-06-2023"
DateTime sessionDate = DateTime.ParseExact(ltrlSessionDate.Text, "dd-MM-yyyy", CultureInfo.InvariantCulture);
Thanks
Hi
I am geeting above error on below line. In ltrlSessionDate.Text value is "21-06-2023"
DateTime sessionDate = DateTime.ParseExact(ltrlSessionDate.Text, "dd-MM-yyyy", CultureInfo.InvariantCulture);
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Naimish MakwanaPosted Apr 20, 2023, 4:52 AM
The error you are encountering could occur due to a few different reasons.
First, make sure that the value of
ltrlSessionDate.Textis indeed "21-06-2023" and that it is not null or empty.Secondly, ensure that the format specified in
DateTime.ParseExactmatches the format of the date string exactly. In this case, it looks like you are trying to parse a date in the format "dd-MM-yyyy". If the format of the date string is different, you will need to adjust the format string accordingly.Finally, it is possible that the culture specified in
CultureInfo.InvariantCulturemay not be appropriate for the date format you are trying to parse. You may need to specify a different culture that matches the format of the date string.To troubleshoot the issue further, you can try adding some error handling to your code to catch any exceptions that may be thrown during the parsing process. For example:
This will allow you to identify and handle any errors that may occur during the parsing process.
Thanks
Naimish Makwana
Ramco RamcoPosted Apr 20, 2023, 5:40 AM
Hi Naimish
How i can get hiddenfield value in itemdatabound
Thanks
Ramco RamcoPosted Apr 20, 2023, 5:33 AM
Hi Naimish
I have written the same code but still it is giving error. When i comment it workd fine
Thanks
Rajkiran SwainPosted Apr 20, 2023, 5:32 AM
Naimish MakwanaPosted Apr 20, 2023, 5:28 AM
To compare the value of
ltrlSessionDate.Textwith another date in theItemDataBoundevent, you can parse both dates asDateTimeobjects and then compare them using theDateTimecomparison operators.For example, if you have another date stored in a variable
otherDate, you could compare it withltrlSessionDate.Textas follows:In the example above, we parse the value of
ltrlSessionDate.Textas aDateTimeobject using theDateTime.ParseExactmethod, and then compare it withotherDateusing the>operator. You can modify this comparison to use any other comparison operator as needed.Thanks
Ramco RamcoPosted Apr 20, 2023, 5:10 AM
Hi Naimish
I have below code . How in itemdatabound i can compare this with another Date
Value in
ltrlSessionDate.Textis indeed "21-06-2023".Thanks
Rajkiran SwainPosted Apr 20, 2023, 4:51 AM