1. Open a new window and transfer parameters:
Transfer parameters:
Response.Write ("<script> window.open" (' *.aspx?id= ') +this. dropdownlist1.selectindex+ "&id1=" +...+ "') </script>")
Receive parameters:
String a = Request.QueryString ("id");
String B = Request.QueryString ("Id1");
2. Add a dialog box for the button
BUTTON1.ATTRIBUTES.ADD ("onclick", "return confirm (' Confirm? ')");
Button.attributes.add ("onclick", "If" (Confirm (' Are you sure ...? ')) {return true;} Else{return false;} ")
3. Delete table Selected records
int intempid = (int) Mydatagrid.datakeys[e.item.itemindex];
String deletecmd = "Delete from Employee where emp_id =" + intempid.tostring ()
4. Delete the form record warning
private void datagrid_itemcreated (Object Sender,datagriditemeventargs e)
{
Switch (e.item.itemtype)
{
Case ListItemType.Item:
Case ListItemType.AlternatingItem:
Case ListItemType.EditItem:
TableCell Mytablecell;
Mytablecell = e.item.cells[14];
LinkButton Mydeletebutton;
Mydeletebutton = (LinkButton) mytablecell.controls[0];
MYDELETEBUTTON.ATTRIBUTES.ADD ("onclick", "return Confirm" (' You are sure you want to delete this message '); ");
Break
Default
Break
}
}
5. Click on a table row link another page
private void Grdcustomer_itemdatabound (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
Click on the form to open
if (E.item.itemtype = = ListItemType.Item E.item.itemtype = = ListItemType.AlternatingItem)
E.item.attributes.add ("onclick", "window.open" (' default.aspx?id= "+ e.item.cells[0]. Text + "');
}
Double-click a table to connect to another page
In the ItemDataBind event
if (E.item.itemtype = = ListItemType.Item E.item.itemtype = = ListItemType.AlternatingItem)
{
String Orderitemid =e.item.cells[1]. Text;
...
E.item.attributes.add ("OnDblClick", "location.href="). /shippedgrid.aspx?id= "+ Orderitemid +" "");
}
Double-click a table to open a new page
if (E.item.itemtype = = ListItemType.Item E.item.itemtype = = ListItemType.AlternatingItem)
{
String Orderitemid =e.item.cells[1]. Text;
...
E.item.attributes.add ("OnDblClick", "open". /shippedgrid.aspx?id= "+ Orderitemid +" ")";
}
6. Table super Join column pass parameter
<asp:hyperlinkcolumn target= "_blank" headertext= "ID number" datatextfield= "id" navigateurl= "aaa.aspx?id="
<%# DataBinder.Eval (Container.DataItem, data field 1)%> ' & Name= ' <%# DataBinder.Eval (Container.DataItem, "data field 2")%> '/ >
7. Click to change the color of the form
if (E.item.itemtype = = ListItemType.Item E.item.itemtype = = ListItemType.AlternatingItem)
{
E.item.attributes.add ("onclick", "this.style.backgroundcolor= ' #99cc00";
This.style.color= ' ButtonText '; this.style.cursor= ' default ';
}
Written in the _itemdatabound of the DataGrid.
if (E.item.itemtype = = ListItemType.Item E.item.itemtype = = ListItemType.AlternatingItem)
{
E.item.attributes.add ("onmouseover", "this.style.backgroundcolor= ' #99cc00";
This.style.color= ' ButtonText '; this.style.cursor= ' default ';
E.item.attributes.add ("onmouseout", "this.style.backgroundcolor="; this.style.color= '; ");
}
Current 1/7 page 1234567 Next read the full text