ASP. NET Common collection code 3

Source: Internet
Author: User

12. horizontal panel scrolling and vertical auto Scaling

<Asp: Panel style = "overflow-X: Scroll; overflow-Y: auto;"> </ASP: Panel>

13. Press enter to convert to Tab

<script language="javascript" for="document" event="onkeydown">
if(event.keyCode==13 && event.srcElement.type!='button' && event.srcElement.type!='submit' && event.srcElement.type!='reset' && event.srcElement.type!=''&& event.srcElement.type!='textarea');
event.keyCode=9;
</script>
  
onkeydown="if(event.keyCode==13) event.keyCode=9"
  
http://dotnet.aspx.cc/exam/enter2tab.aspx

14. DataGrid super join Column

Datanavigateurlfield = "field name" datanavigateurlformatstring = "http: // XX/INC/Delete. aspx? Id = {0 }"

15. The row of the DataGrid changes color with the mouse

private void DGzf_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType!=ListItemType.Header)
{
e.Item.Attributes.Add( "onmouseout","this.style.backgroundColor=""+e.Item.Style["BACKGROUND-COLOR"]+""");
e.Item.Attributes.Add( "onmouseover","this.style.backgroundColor=""+ "#EFF3F7"+""");
}
}

16. template Column

<Asp: templatecolumn visible = "false" sortexpression = "Demo" headertext = "ID">
<Itemtemplate>
<Asp: Label text = '<% # databinder. eval (container. dataitem, "ArticleID") %> 'runat = "server" width = "80%" id = "lblcolumn"/>
</Itemtemplate>
</ASP: templatecolumn>
  
<Asp: templatecolumn headertext = "selected">
<Headerstyle wrap = "false" horizontalalign = "center"> <Itemtemplate>
<Asp: checkbox id = "chkexport" runat = "server"/>
</Itemtemplate>
<Edititemtemplate>
<Asp: checkbox id = "chkexporton" runat = "server" enabled = "true"/>
</Edititemtemplate>
</ASP: templatecolumn>

Background code

Protected void checkall_checkedchanged (Object sender, system. eventargs E)
{
// Change the column selection to select all or all columns.
Checkbox chkexport;
If (checkall. Checked)
{
Foreach (maid in mydatagrid. Items)
{
Chkexport = (checkbox) odatagriditem. findcontrol ("chkexport ");
Chkexport. Checked = true;
}
}
Else
{
Foreach (maid in mydatagrid. Items)
{
Chkexport = (checkbox) odatagriditem. findcontrol ("chkexport ");
Chkexport. Checked = false;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.