29. Use the DataGrid: Confirm deletion: Private void maid (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E) { Foreach (maid di in this. Maid) { If (Di. itemtype = listitemtype. Item | Di. itemtype = listitemtype. alternatingitem) { (Linkbutton) Di. cells [8]. controls [0]). Attributes. Add ("onclick", "Return confirm ('Are you sure you want to delete this item? ');"); } } } 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';" ; } 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(); 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. AppSettings["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 ); 33. 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> The text box name must be the name on the Web page you want to log on to. If the source code is not working, you can use vsniffer to check it.
The following code obtains the login information entered by the user: string name; name=Request.QueryString["EmailName"];
try { int a=name.IndexOf("@",0,name.Length); f_user.Value=name.Substring(0,a); f_domain.Value=name.Substring(a+1,name.Length-(a+1)); f_pass.Value=Request.QueryString["Psw"]; }
Catch { Script. Alert ("wrong email! "); Server. Transfer ("index. aspx "); }
|