11.自定义异常处理
//
自定义异常处理类
using System;
using System.Diagnostics;
namespace MyAppException
12.Panel 横向滚动,纵向自动扩展
using System;
using System.Diagnostics;
namespace MyAppException
<asp:panelstyle="overflow-x:scroll;overflow-y:auto;"></asp:panel>
13.回车转换成Tab
<scriptlanguage
=
"
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超级连接列
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 "
DataNavigateUrlField="字段名"DataNavigateUrlFormatString="http://xx/inc/delete.aspx?ID={0}"
15.DataGrid行随鼠标变色
private
void
DGzf_ItemDataBound(
object
sender,System.Web.UI.WebControls.DataGridItemEventArgse)
{
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.模板列
{
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 " + " \ "" );
}
}
<ASP:TEMPLATECOLUMNvisible="False"sortexpression="demo"headertext="ID">
<ITEMTEMPLATE>
<ASP:LABELtext=’<%#DataBinder.Eval(Container.DataItem,"ArticleID")%>’runat="server"width="80%"id="lblColumn"/>
</ITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>
<ASP:TEMPLATECOLUMNheadertext="选中">
<HEADERSTYLEwrap="False"horizontalalign="Center"></HEADERSTYLE>
<ITEMTEMPLATE>
<ASP:CHECKBOXid="chkExport"runat="server"/>
</ITEMTEMPLATE>
<EDITITEMTEMPLATE>
<ASP:CHECKBOXid="chkExportON"runat="server"enabled="true"/>
</EDITITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>
<ITEMTEMPLATE>
<ASP:LABELtext=’<%#DataBinder.Eval(Container.DataItem,"ArticleID")%>’runat="server"width="80%"id="lblColumn"/>
</ITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>
<ASP:TEMPLATECOLUMNheadertext="选中">
<HEADERSTYLEwrap="False"horizontalalign="Center"></HEADERSTYLE>
<ITEMTEMPLATE>
<ASP:CHECKBOXid="chkExport"runat="server"/>
</ITEMTEMPLATE>
<EDITITEMTEMPLATE>
<ASP:CHECKBOXid="chkExportON"runat="server"enabled="true"/>
</EDITITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>
后台代码
protected void CheckAll_CheckedChanged( object sender,System.EventArgse)
{
// 改变列的选定,实现全选或全不选。
CheckBoxchkExport;
if (CheckAll.Checked)
{
foreach (DataGridItemoDataGridItem in MyDataGrid.Items)
{
chkExport = (CheckBox)oDataGridItem.FindControl( " chkExport " );
chkExport.Checked = true ;
}
}
else
{
foreach (DataGridItemoDataGridItem in MyDataGrid.Items)
{
chkExport = (CheckBox)oDataGridItem.FindControl( " chkExport " );
chkExport.Checked = false ;
}
}
}
17.数字格式化
protected void CheckAll_CheckedChanged( object sender,System.EventArgse)
{
// 改变列的选定,实现全选或全不选。
CheckBoxchkExport;
if (CheckAll.Checked)
{
foreach (DataGridItemoDataGridItem in MyDataGrid.Items)
{
chkExport = (CheckBox)oDataGridItem.FindControl( " chkExport " );
chkExport.Checked = true ;
}
}
else
{
foreach (DataGridItemoDataGridItem in MyDataGrid.Items)
{
chkExport = (CheckBox)oDataGridItem.FindControl( " chkExport " );
chkExport.Checked = false ;
}
}
}
【<%#Container.DataItem("price")%>的结果是500.0000,怎样格式化为500.00?】
<%#Container.DataItem("price","{0:¥#,##0.00}")%>
inti=123456;
strings=i.ToString("###,###.00");
</di
<%#Container.DataItem("price","{0:¥#,##0.00}")%>
inti=123456;
strings=i.ToString("###,###.00");
</di
发表评论
评论