You've asked this question many many times. My question to you us why do you ignore the solution when the solution is so very simple. All you have to do is create separate columns to hold the "J", the date, and the sequence. Once you create a proper design,
again this has been explained many many times, all you have left is a basic "if" condition. If today;s date does not exist then then the sequence is 001 otherwise increment the sequence column. Very Very simple... Please at least try the solution.
According to your description, I need to confirm a few questions with you.
First, does your Textbox1 only allow numbers, and does it have a range limit?
Second, is the content displayed in gridview based on the largest data record corresponding to the current date in the database?
For example, when you enter 3, should you first go to the database to get the maximum value of the current date, and increase the number of corresponding input values up according to the maximum value. (You enter
3, the same date records in database max value is 2 ,then you will show 3,4,5, right?)
Finally, do you save the current data only when you click the save button?
Based on the above issues, I set a limit on Textbox1 in the range of 1-99 and added validation using the server validation control.
Then I created a table named DateRecordin database to store the data every time I click the save button.
My idea is to trigger the OnTextChangedevent of Textbox1 , first get the maximum number of the DateRecord table in database that coincides with the current date, decide which data to display from, display the data in GridView through a loop, and
save the data of the current page with
session.
Then, by saving the click event of the button, the current data saved in the session is obtained and stored in the database.
Here is my detailed code, which you can refer to:
DateRecord table:
CREATE TABLE [dbo].[DateRecord] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Number] NVARCHAR (MAX) NOT NULL,
CONSTRAINT [PK_DateRecord] PRIMARY KEY CLUSTERED ([Id] ASC)
);
Member
310 Points
720 Posts
How To Get Date In Sequeences
Dec 23, 2019 10:29 AM|Gopi.MCA|LINK
Hello
Assume I have Table1 in which i have one field In Textbox1 i will give you 3 and assume todays date is 23-Dec-2019
Now in gridview i want to show
J20191223001
J20191223002
J20191223003
On click it will save database.. that will do later again i have in textbox1 value :4
now i want
J20191223004
J20191223005
J20191223006
J20191223007
Next Date is 24-Dec-2019 now i have enter Textbox1 is 2
now i want like this again
J20191224001
J20191224002
How to do so
Thanking You
All-Star
53761 Points
24071 Posts
Re: How To Get Date In Sequeences
Dec 23, 2019 11:26 AM|mgebhard|LINK
You've asked this question many many times. My question to you us why do you ignore the solution when the solution is so very simple. All you have to do is create separate columns to hold the "J", the date, and the sequence. Once you create a proper design, again this has been explained many many times, all you have left is a basic "if" condition. If today;s date does not exist then then the sequence is 001 otherwise increment the sequence column. Very Very simple... Please at least try the solution.
Contributor
3720 Points
1043 Posts
Re: How To Get Date In Sequeences
Dec 24, 2019 06:44 AM|Yongqing Yu|LINK
Hi Gopi.MCA,
According to your description, I need to confirm a few questions with you.
First, does your Textbox1 only allow numbers, and does it have a range limit?
Second, is the content displayed in gridview based on the largest data record corresponding to the current date in the database?
For example, when you enter 3, should you first go to the database to get the maximum value of the current date, and increase the number of corresponding input values up according to the maximum value. (You enter 3, the same date records in database max value is 2 ,then you will show 3,4,5, right?)
Finally, do you save the current data only when you click the save button?
Based on the above issues, I set a limit on Textbox1 in the range of 1-99 and added validation using the server validation control.
Then I created a table named DateRecord in database to store the data every time I click the save button.
My idea is to trigger the OnTextChanged event of Textbox1 , first get the maximum number of the DateRecord table in database that coincides with the current date, decide which data to display from, display the data in GridView through a loop, and save the data of the current page with session.
Then, by saving the click event of the button, the current data saved in the session is obtained and stored in the database.
Here is my detailed code, which you can refer to:
DateRecord table:
Add this setting in your web.config:
aspx code :
aspx.cs code:
Here is the result of this work demo:
Best Regards,
YongQing.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.