|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在实现ERP等高端的ASP应用时,用户需要提供核心的经营资料,需要ASP商有很高的信用度。楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。datagrid|办理|成绩Introduction
TheDataGridWebservercontrolisapowerfultoolfordisplayinginformationfromadatasource.Itiseasytouse;youcandisplayeditabledatainaprofessional-lookinggridbysettingonlyafewproperties.Atthesametime,thegridhasasophisticatedobjectmodelthatprovidesyouwithgreatflexibilityinhowyoudisplaythedata.
Thispaperaddressessomeofthequestionsaboutcustomizinggriddisplaythatarecommonlyaskedinnewsgroups,onWebsites,andinotherdeveloperforums.Thetechniquesdescribedherearesometimesquitesimpleandatothertimessomewhatinvolved.Ineachcase,however,theyaddressaquestionofhowtogobeyondthebasicfunctionalityoftheDataGridcontrol.
Thispaperassumesthatyouarealreadyfamiliarwiththecontrol―howtoaddittoaformandconfigureittodisplaydata.Youshouldalsounderstandhowtoputarowinthegridintoeditmodeandotherbasictasks.(Fordetails,seeDataGridWebServerControl.)Finally,youwillfindithelpfultoknowhowtoworkwithtemplates―addingtemplatecolumnstothegridandlayoutoutcontrolsinsideatemplate.
WindowsFormsversusWebFormsDataGridControl
TheWebFormsDataGridcontrolisnotthesameastheWindowsFormsequivalent.Itisacommon(andnotunreasonable)assumptionthattheyarethesamecontrol,oratleasthaveidenticalfunctionality.However,theentireprogrammingparadigmforWebFormsisquitedifferentfromthatforWindowsForms.Forexample,WebFormspagesperformaroundtriptotheserverforanyprocessing;theymustmanagestate;theyfeatureaverydifferentdata-bindingmodel;andsoon.
Becauseofthesedifferences,therearealsosignificantdifferencesintheirrespectivecontrols,includingtheDataGridcontrol.Asageneralrule,theWebFormsDataGridcontrolincludeslessbuilt-infunctionality.AfewexamplesofdifferencesintheWebFormsDataGridcontrolare:
Itdoesnotinherentlysupportmaster-detaildatastructures.
AswithotherWebservercontrols,itdoesnotsupporttwo-waydatabinding.Ifyouwanttoupdatedata,youmustwritecodetodothisyourself.
Youcanonlyeditonerowatatime.
Itdoesnotinherentlysupportsorting,althoughitraiseseventsyoucanhandleinordertosortthegridcontents.
Ontheotherhand:
YoucanbindtheWebFormsDataGridtoanyobjectthatsupportstheIEnumerableinterface.
TheWebFormsDataGridcontrolsupportspaging.
ItiseasytocustomizetheappearanceandlayoutoftheWebFormsDataGridcontrolascomparedtotheWindowsFormsone.(Detailsareprovidedlaterinthispaper.)
ControllingColumnWidth,Height,andAlignment
Bydefault,theDataGridcontrolsizesrowsandcolumnstofittheoverallheightandwidththatyouhaveassignedtothegrid.Withintheoverallgridwidth,itsizescolumnsaccordingtothewidthofthecolumnheadingtext.Alldataisdisplayedleft-justifiedbydefault.
Tocontrolcolumncharacteristics,youshouldturnoffautocolumngenerationbysettingtheAutoGenerateColumnspropertytofalse.Infact,youshouldsetthispropertytotrueonlyforshort-termuses,suchasquickproof-of-conceptpagesordemonstrations.Forproductionapplications,youshouldaddcolumnsexplicitly.Theindividualcolumnscanbeboundcolumnsortemplatecolumns.
Tosetthecolumnwidth,youcreateastyleelementforthatcolumnandthensettheelementsWidthpropertytostandardunits(say,pixels).ThefollowingexampleshowsyouwhattheHTMLsyntaxlookslikeforanItemStyleelementwithitsWidthpropertyset.
<asp:BoundColumnDataField="title"SortExpression="title"
HeaderText="Title">
<ItemStyleWidth="100px"></ItemStyle>
</asp:BoundColumn>
Alternatively,youcandothesamethingbysettingtheItemStylepropertydirectlyintheelement,asinthefollowingexample:
<asp:BoundColumnItemStyle-Width="100px"DataField="title"
SortExpression="title"HeaderText="Title">
</asp:BoundColumn>
Youcansetalignmentusingthestyleelement,settingitto"Right,""Left,"andothervaluesdefinedintheHorizontalAlignenumeration.(InVisualStudio,alignmentisavailableforindividualcolumnsintheFormattabofthegridsPropertybuilder.)Thefollowingisanexample:
<asp:BoundColumnDataField="title"SortExpression="title"
HeaderText="Title">
<ItemStyleWidth="100px"HorizontalAlign="Right"></ItemStyle>
</asp:Bound</p>[1][2][3][4][5][6][7][8][9][10]下一页>>
asp,jsp,php是web开发的三大技术,asp简单易用且有microsoft做靠山,jsp功能强大是因为有java支持,php则开源跨平台.在国内,asp应用范围最广,jsp发展势头最猛,php则处于劣势.这可能与公司的支持以及技术的培训有关. |
|