1. Calculate the number of days between two dates
System. DateTime dtA = (DateTime) this. StartDate. Text;
System. DateTime dtB = (DateTime) this. EndDate. Text;
TimeSpan c = db-da;
Response. Write (c. TotalDays );
2. string format required for date conversion
Calendar2.SelectedDate. ToString ("yyyy-MM-dd"); after the calendar control selects a date, it is converted to the required string format. The format here is case-sensitive rotation. I don't understand why the month is case-sensitive, but it is not supported in lower case.
3. Implementation of control-level attributes
1 # region control attributes
2 // true-show all columns false-hide some columns
3 public bool IsVisible
4 {
5 get
6 {
7 return (ViewState ["IsVisible"] = null )? True: bool. Parse (ViewState ["IsVisible"]. ToString ());
8}
9 set
10 {
11 ViewState ["IsVisible"] = value;
12}
13}
14
15 // display data type 0-submit 1-to-do
16 public int ShowType
17 {
18 get
19 {
20 return (ViewState ["ShowType"] = null )? 0: int. Parse (ViewState ["ShowType"]. ToString ());
21}
22 set
23 {
24 ViewState ["ShowType"] = value;
25}
26}
27 # endregion
28
I have never understood the usage of viewstate before. Now I have used it and finally understood it. It seems that it is really important to accumulate experience in practice :)