About dynamic use Web User control problems:
Existing control Webusercontrol1 , A page Webform1.aspx , There is Table1 Of Table Control, now you want Table Add several dynamic Webusercontrol1 . I do this:
For (INT I = 0; I <10; I ++ ){
Webusercontrol1 WUC = new webusercontrol1 ();
Tablecell Tc = new tablecell ();
TC. Controls. Add (WUC );
Tablerow TR = new tablerow ();
Tr. cells. Add (TC );
Table1.rows. Add (TR );
}
Solved! Not usedNewMethod, but useLoadcontrolMethod! Haha.
C # How to obtain the first day of this month?
New datetime (datetime. Now. Year, datetime. Now. month, 1)
Excuse me C # Is it equivalent STL In Set And Map Container
Sortedlist It can be considered Map, Set What about it? Other feelings Collection In Arraylist It can contain any Type object. It is not good if you do not set the type limit.
Hashtable Yes <Key, value> With Set It should be different.
Use Databind After that, you can easily display database records, <% # Databinder. eval (...) %> Only strings can be displayed. Eval The calculated data shows different content, for example, the value may have 1 , 2 , 3 , 4 , 5 Are displayed according to the value size. 1 , 2 , 3 , 4 , 5 What should a star do? ?
Eval Only convert the data type. In fact, if you are sure that your data source type is correct, you can get more Good performance. The data source is an implementation Ienumerable Interface Class. For example, if your data source is Int [] , Then you can display the statement <% (INT) container. dataitem). tostring () %> To replace Databinder. So you can use
<% # If (INT) container. dataitem = someint) response. Write ( " The integer is "+ Someint. tostring ()) %>
To achieve the effect you want.