|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
实不相瞒,Java是我见过的执行效率最低的程序设计语言,前不久在CSDN论坛上有个评测,计算9999的阶乘,同样的循环算法,Java的耗时是.NET的5倍。datagrid|创立在利用DataGrid时,假如页面很长,大概必要用户本人来拉动转动条,上面的例籽实现了主动转动的功效。其基础道理就是使用了LinkButton的锚点的功效,假如利用PushButton,那还必需本人增加锚点。别的必需弄分明的是Page的PostBack时的客户端剧本:
<scriptlanguage="<ahref="http://dev.21tx.com/web/javascript/"target="_blank">JavaScript</a>">
<!--
function__doPostBack(eventTarget,eventArgument){
vartheform=document.Form1;
theform.__EVENTTARGET.value=eventTarget;
theform.__EVENTARGUMENT.value=eventArgument;
theform.submit();
}
//-->
</script>
这段剧本中__doPostBack函数有两个参数:第一个eventTarget是触发PostBack的控件的UniqueID;第二参数eventArgument是一个工具,包括PostBack的分外信息。因而我们利用UniqueID来作为锚点的值。
源代码以下:
检察例子
DataGridAutoScroll.ASPx
<%@PageLanguage="<ahref="http://dev.21tx.com/language/vb/"target="_blank">VB</a>"AutoEventWireup="false"Codebehind="DataGridAutoScroll.aspx.vb"
Inherits="aspx<ahref="http://dev.21tx.com/web/"target="_blank">Web</a>.DataGridAutoScroll"%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<HTML>
<HEAD>
<titlerunat="server"id="mengxianhui"></title>
<metaname="GENERATOR"content="MicrosoftVisualStudio<ahref="http://dev.21tx.com/dotnet/"target="_blank">.net</a>7.0">
<metaname="CODE_LANGUAGE"content="VisualBasic7.0">
<metaname="vs_defaultClientScript"content="<ahref="http://dev.21tx.com/java/"target="_blank">Java</a>Script">
<metaname="vs_targetSchema"content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<formid="Form1"method="post"runat="server">
<asp:DataGridid="DataGrid1"runat="server"BorderColor="#CC9966"BorderStyle="None"
BorderWidth="1px"BackColor="White"CellPadding="4">
<SelectedItemStyleFont-Bold="True"ForeColor="#663399"BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyleForeColor="#330099"BackColor="White"></ItemStyle>
<HeaderStyleFont-Bold="True"ForeColor="#FFFFCC"BackColor="#990000"></HeaderStyle>
<FooterStyleForeColor="#330099"BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:EditCommandColumnButtonType="LinkButton"UpdateText="Update"
CancelText="Cancel"EditText="Edit"></asp:EditCommandColumn>
</Columns>
<PagerStyleHorizontalAlign="Center"ForeColor="#330099"BackColor="#FFFFCC"></PagerStyle>
</asp:DataGrid>
</form>
</body>
</HTML>
代码:DataGridAutoScroll.aspx.vb
ImportsSystem
ImportsSystem.Web
ImportsSystem.Web.UI.WebControls
ImportsSystem.Collections
ImportsSystem.Data
ImportsSystem.Data.SqlClient
PublicClassDataGridAutoScroll
InheritsSystem.Web.UI.Page
ProtectedWithEventsDataGrid1AsSystem.Web.UI.WebControls.DataGrid
ProtectedmengxianhuiAsNewHtmlGenericControl()
#Region"WebFormDesignerGeneratedCode"
<System.Diagnostics.DebuggerStepThrough()>PrivateSubInitializeComponent()
EndSub
PrivateSubPage_Init(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Init
InitializeComponent()
EndSub
#EndRegion
PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load
mengxianhui.InnerText="【孟宪会之出色天下】之.NET开辟者场地"
IfNotPage.IsPostBackThen
DataGrid1.DataSource=CreateDataSource()
DataGrid1.DataBind()
Else
DimstartUpScriptAsString
startUpScript="<scriptlanguage=Javascript>location.href=#"_
&Request.Form("__EVENTTARGET")&";</script>"
Me.RegisterStartupScript(Me.UniqueID&"StartUp",startUpScript)
EndIf
EndSub
FunctionCreateDataSource()AsICollection
DimdtAsDataTable
DimdrAsDataRow
DimiAsInteger
创立DataTable
dt=NewDataTable()
dt.Columns.Add(NewDataColumn("字符型值",GetType(String)))
dt.Columns.Add(NewDataColumn("布尔型值",GetType(Boolean)))
dt.Columns.Add(NewDataColumn("泉币型值",GetType(Double)))
示例数据
Fori=1To150
dr=dt.NewRow()
dr(0)="Item"+i.ToString()
If(iMod20)Then
dr(1)=True
Else
dr(1)=False
EndIf
dr(2)=1.23*(i+1)
向datatable增加row
dt.Rows.Add(dr)
Next
前往DataTable的DataView
CreateDataSource=NewDataView(dt)
EndFunction
PrivateSubDataGrid1_ItemDataBound(ByValsenderAsObject,_
ByValeAsSystem.Web.UI.WebControls.DataGridItemEventArgs)HandlesDataGrid1.ItemDataBound
SelectCasee.Item.ItemType
CaseListItemType.Item,ListItemType.AlternatingItem
DimeditButtonAsLinkButton=NewLinkButton()
editButton=CType(e.Item.Cells(0).Controls(0),LinkButton)
editButton.Attributes.Add("name","#"&editButton.UniqueID)
CaseListItemType.EditItem
DimUpdateButtonAsLinkButton=NewLinkButton()
UpdateButton=CType(e.Item.Cells(0).Controls(0),LinkButton)
UpdateButton.Attributes.Add("name","#"&UpdateButton.UniqueID)
EndSelect
EndSub
PrivateSubDataGrid1_EditCommand(ByValsourceAsObject,_
ByValeAsSystem.Web.UI.WebControls.DataGridCommandEventArgs)HandlesDataGrid1.EditCommand
DataGrid1.EditItemIndex=e.Item.ItemIndex
DataGrid1.DataSource=CreateDataSource()
DataGrid1.DataBind()
EndSub
PrivateSubDataGrid1_CancelCommand(ByValsourceAsObject,_
ByValeAsSystem.Web.UI.WebControls.DataGridCommandEventArgs)HandlesDataGrid1.CancelCommand
DataGrid1.EditItemIndex=-1
DataGrid1.DataSource=CreateDataSource()
DataGrid1.DataBind()
EndSub
PrivateSubDataGrid1_UpdateCommand(ByValsourceAsObject,_
ByValeAsSystem.Web.UI.WebControls.DataGridCommandEventArgs)HandlesDataGrid1.UpdateCommand
DataGrid1.EditItemIndex=-1
DataGrid1.DataSource=CreateDataSource()
DataGrid1.DataBind()
EndSub
EndClass我也不知道,我原来理解的,NET就是C++编程,只是与JAVA相对,呵呵。以为.ET就是高级C++编程。 |
|