13.回车转换成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"
复制代码 14.DataGrid超级连接列 - DataNavigateUrlField="字段名" DataNavigateUrlFormatString="http://xx/inc/delete.aspx?ID={0}"
复制代码 15.DataGrid行随鼠标变色 - 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.模板列 - <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="选中">
- <HEADERSTYLE wrap="False" horizontalalign="Center"></HEADERSTYLE>
- <ITEMTEMPLATE>
- <ASP:CHECKBOX id="chkExport" runat="server" />
- </ITEMTEMPLATE>
- <EDITITEMTEMPLATE>
- <ASP:CHECKBOX id="chkExportON" runat="server" enabled="true" />
- </EDITITEMTEMPLATE>
- </ASP:TEMPLATECOLUMN>
复制代码 后台代码 - protected void CheckAll_CheckedChanged(object sender, System.EventArgs e)
- {
- //改变列的选定,实现全选或全不选。
- CheckBox chkExport ;
- if( CheckAll.Checked)
- {
- foreach(DataGridItem oDataGridItem in MyDataGrid.Items)
- {
- chkExport = (CheckBox)oDataGridItem.FindControl("chkExport");
- chkExport.Checked = true;
- }
- }
- else
- {
- foreach(DataGridItem oDataGridItem in MyDataGrid.Items)
- {
- chkExport = (CheckBox)oDataGridItem.FindControl("chkExport");
- chkExport.Checked = false;
- }
- }
- }
复制代码 |