SoFunction
Updated on 2025-04-09

Thirty-three commonly used codes


29. DataGrid uses:
Add and delete confirmation:
private void DataGrid1_ItemCreated(object sender,  e) 

 foreach(DataGridItem di in this.) 
 { 
if(====) 

((LinkButton)[8].Controls[0]).("onclick","return confirm('Can you confirm deletion of this item?');");

 } 

Alternating styles:
ListItemType itemType = ; 
if (itemType ==  ) 

 ["onmouseout"] = "javascript:='#FFFFFF';"; 
 ["onmouseover"] = "javascript:='#d9ece1';cursor='hand';" ; 

else if( itemType == ) 

 ["onmouseout"] = "javascript:='#a0d7c4';"; 
 ["onmouseover"] = "javascript:='#d9ece1';cursor='hand';" ; 

Add a numbered column:
DataTable dt= (sqltxt); //Execute DataTable returned by sql
DataColumn dc=("number",("")); 
for(int i=0;i<;i++) 

 [i]["number"]=(i+1).ToString(); 

=dt; 
(); 
Add a CheckBox to DataGrid1, add a checkbox to the page.
private void CheckBox2_CheckedChanged(object sender,  e) 

 foreach(DataGridItem thisitem in ) 
 { 
((CheckBox)[0].Controls[1]).Checked=; 
 } 

Delete all the data displayed in DataGrid1 in the current page.
foreach(DataGridItem thisitem in ) 

 if(((CheckBox)[0].Controls[1]).Checked) 
 { 
string strloginid= [].ToString(); 
Del (strloginid); //Delete function
 } 

30. When the file is in a different directory, you need to get the database connection string (if the connection string is placed, then initialize it in it)
Add the following code in Application_Start:
Application["ConnStr"]=+ConfigurationSettings. 
 AppSettings["ConnStr"].ToString(); 
31. Variable.ToString()
Character conversion to string
("n"); //Generate 12,345.00
("C"); // Generate ¥12,345.00
("e"); //Generate 1.234500e+004
("f4"); //Generate 12345.0000
("x"); //Generate 3039 (hexadecimal)
("p"); // Generate 1,234,500.00%
32. Variable.Substring(parameter 1, parameter 2);
Intercept part of the string, parameter 1 is the number of left starting digits, and parameter 2 is the number of intercepted digits. For example: string s1 = (0,2);
33. Log in to other websites on your own website: (If your page is nested, because one page can only have one FORM, you can then direct to another page and submit login information)
<SCRIPT language="javascript"> 
<!-- 
 function gook(pws) 
 { 
(); 
 } 
//--> 
</SCRIPT> <body leftMargin="0" topMargin="0" onload="javascript:gook()" marginwidth="0" marginheight="0"> 
<form name="frm" action=" http://220.194.55.68:6080/?retid=7259 " method="post"> 
<tr> 
<td> 
<input  type="hidden" size="1" name="f_user" runat="server"> 
<input  type="hidden" size="1" name="f_domain" runat="server"> 
<input class="box"  type="hidden" size="1" name="pwshow" runat="server"> 
<INPUT  type="hidden" maxLength="20" size="1" value="5" name="lng"> 
<INPUT  type="hidden" size="1" value="2" name="tem"> 
</td> 
</tr> 
</form> 
The name of the text box must be the name on the web page you want to log in. If the source code is not working, you can use vsniffer to check it out.
The following is the code to obtain the login information entered by the user:
string name; 
name=["EmailName"]; 
try 

 int a=("@",0,); 
 f_user.Value=(0,a); 
 f_domain.Value=(a+1,-(a+1)); 
 f_pass.Value=["Psw"]; 

catch 

("Wrong email!");
 ("");