3.2 style alternation:
ListItemType itemType = e.Item.ItemType;
if (itemType == ListItemType.Item )
{
e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#FFFFFF';";
e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#d9ece1';cursor='hand';" ;
}
else if( itemType == ListItemType.AlternatingItem)
{
e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#a0d7c4';";
e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#d9ece1';cursor='hand';" ;
}
3.3 Add an ID column:
Datatable dt = C. executertntableforaccess (sqltxt); // execute the datatable returned by the SQL statement
Datacolumn Dc = DT. Columns. Add ("Number", system. type. GetType ("system. String "));
For (INT I = 0; I <DT. Rows. Count; I ++)
{
DT. Rows [I] ["Number"] = (I + 1). tostring ();
}
Datagrid1.datasource = DT;
Datagrid1.databind ();
3.4 add a checkbox in datagrid1, and add a select-All box to the page
private void CheckBox2_CheckedChanged(object sender, System.EventArgs e)
{
foreach(DataGridItem thisitem in DataGrid1.Items)
{
((CheckBox)thisitem.Cells[0].Controls[1]).Checked=CheckBox2.Checked;
}
}
Delete all data displayed on the current page.
Foreach (maid)
{
If (checkbox) thisitem. cells [0]. controls [1]). Checked)
{
String strloginid = maid [thisitem. itemindex]. tostring ();
Del (strloginid); // delete a function
}
}
30. When the file is in different directories, you need to obtain the database connection string (if the connection string is placed in Web. config and then initialized in global. asax)
Add the following code to application_start:
Application ["connstr"] = This. Context. Request. physicalapplicationpath + configurationsettings. receivettings ["connstr"]. tostring ();
31. Variable. tostring ()
Convert string to string
12345. tostring ("N"); // generate 12,345.00
12345. tostring ("C"); // generate $12,345.00
12345. tostring ("e"); // generate 1.234500e + 004
12345. tostring ("F4"); // generate 12345.0000
12345. tostring ("X"); // generate 3039 (hexadecimal)
12345. tostring ("p"); // generate 1,234,500.00%
32. Variable. substring (parameter 1, parameter 2 );
Part of the string to be truncated. Parameter 1 is the start number of digits on the left, and parameter 2 is the number of digits to be truncated.
For example, string S1 = Str. substring );
34. log on to another website on your website: (if your page is nested, because one page can only have one form, you can direct the page to another and submit the login information)
<SCRIPT language="javascript">
<!--
function gook(pws)
{
frm.submit();
}
//-->
</SCRIPT> <body leftMargin="0" topMargin="0" onload="javascript:gook()" marginwidth="0" marginheight="0">
<form name="frm" action=" http://220.194.55.68:6080/login.php?retid=7259 " method="post">
<tr>
<td>
<input id="f_user" type="hidden" size="1" name="f_user" runat="server">
<input id="f_domain" type="hidden" size="1" name="f_domain" runat="server">
<input class="box" id="f_pass" type="hidden" size="1" name="pwshow" runat="server">
<INPUT id="lng" type="hidden" maxLength="20" size="1" value="5" name="lng">
<INPUT id="tem" type="hidden" size="1" value="2" name="tem">
</td>
</tr>
</form>