ASPNET五大數(shù)據(jù)控件_第1頁
ASPNET五大數(shù)據(jù)控件_第2頁
ASPNET五大數(shù)據(jù)控件_第3頁
ASPNET五大數(shù)據(jù)控件_第4頁
ASPNET五大數(shù)據(jù)控件_第5頁
已閱讀5頁,還剩51頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、數(shù)據(jù)綁定控件比較 (ReapterDataListGridViewDatailsViewFormView):1.插入功能方面:DetailsView和FormView具有插入功能,其它控件沒有2.模板DataLisstForrmViewwRepeeater三三種必須編輯輯模板,而GridVieew和DettailsVView只有有在將列轉(zhuǎn)換換成模板列以以后才會出現(xiàn)現(xiàn)各種模板.3.自動分頁功功能GridVieew ,DeetailssView和和FormVView都是是2.0版本本新增控件,內(nèi)置了分頁頁,排序等等等功能,其他需要手工定定義4.數(shù)據(jù)呈現(xiàn)方方式:GridVieew,DattaList

2、t,Repeeator用用于呈現(xiàn)多列列數(shù)據(jù),DetailssView,FormVView用于于呈現(xiàn)單列數(shù)數(shù)據(jù),即常用用的數(shù)據(jù)明細(xì)細(xì). DataLisst和Reaapter都都需要編輯模模板列,而在在模板列當(dāng)中中可以添加TTextBoox,同時可可以指定TeextBoxx的ID從而而實現(xiàn)提取用用戶輸入的值值,但是DaataGriid和GriidVieww兩個件是不不需要編輯模模板的,它的的編輯功能是是自動生成的的我們無法知知道那些文本本框的ID,也也就無法通過過ID來獲取取用戶的輸入入,那么可以以通過對單元元格的引用來來實現(xiàn):privatee voidd DataaGrid11_UpdaateC

3、ommmand(objecct souurce,xxx) strring bbkid=DDataGrrid1.DDataKeeyse.Item.ItemIIndex.toSttring();/提提取主鍵 strring bbktitlle=(TTextBoox)e.IItem.CCells1.Coontrolls0).Textt;/提取取用戶的輸入入一.進(jìn)入編輯狀狀態(tài):DataLisst1.EdditIteemIndeex = ee.Itemm.ItemmIndexx;DataGriid1.EdditIteemIndeex = ee.Itemm.ItemmIndexx;GridVieew1.E

4、dditInddex = e.NewwEditIIndex;DetailssView11.ChanngeModde(DettailsVViewMoode.Eddit);/進(jìn)入編輯輯狀態(tài)DetailssView11.ChanngeModde(DettailsVViewMoode.ReeadOnlly);/退出編輯狀狀態(tài)二.設(shè)置主鍵:DataLisst1.DaataKeyyFieldd = bbkid;DataGriid1.DaataKeyyFieldd = bbkid;string strr=bkkid;GridVieew1.DaataKeyyNamess = sttr;三.提取主鍵:strin

5、g bkid = DattaListt1.DattaKeysse.Ittem.IttemInddex.TToStriing();/DattaListtstring bkid = DattaGridd1.DattaKeysse.Ittem.IttemInddex.TToStriing();/DattaGriddstring bkid = GriidVieww1.DattaKeysse.RoowIndeex.Vaalue.TToStriing();/GriidViewwstring bkid = DettailsVView1.DataKKey0.ToSttring();四.查找控件:string

6、bktittle = (TexxtBox)e.Iteem.FinndConttrol(txtTiile).Textt;/DaataLisststring bktittle = (TexxtBox)e.Iteem.Cellls1.Conttrols0).TText;/DataaGridstring bktittle = (TexxtBox)GridVView1.Rowse.RowwIndexx.Cellls1.Conttrols0).TText;string bktittle = (TexxtBox)DetaiilsVieew1.Roows1.Cellls1.Contrrols00).Teext

7、;注意查找控件有有兩種方法:(各數(shù)據(jù)綁綁定控件的都都可以用下面面兩種方法進(jìn)進(jìn)行查找)1.如果知道控控件的ID可可以用這種方方法(TextBBox)e.Item.FindCControol(txxtTilee).TText;/這是查找找2.如果不知道道控件的IDD可用這種方方法(TextBBox)e.Item.Cellss1.CControols0).Texxt;/這這是索引五.給刪除按鈕鈕添加確認(rèn):protectted vooid DaataLisst1_IttemDattaBounnd(objject ssenderr, DattaListtItemEEventAArgs ee) if (e

8、.Ittem.IttemTyppe = ListIItemTyype.Ittem | e.Ittem.IttemTyppe = ListIItemTyype.AllternaatingIItem) LinkkButtoon lbttn =(LLinkBuutton) e.Ittem.FiindConntrol(lbtnndelette); lbtnn.Attrributees.Addd(OnCClick,retturn cconfirrm(確定要刪除除嗎?); protectted vooid DaataGriid1_IttemDattaBounnd(objject ssenderr, Dat

9、taGriddItemEEventAArgs ee) if(e.Iteem.IteemTypee=LisstItemmType.Item | e.Item.ItemTType=ListIItemTyype.AllternaatingIItem) LinkkButtoon lbttn = (LinkBButtonn)e.Ittem.Ceells33.Conntrolss0; lbtnn.Attrributees.Addd(OnCClick,retturn cconfirrm(確認(rèn)刪除?); protectted vooid GrridVieew1_RoowDataaBoundd(objeect

10、seender, GriddViewRRowEveentArggs e) if(e.Roww.RowTType= DataaContrrolRowwType.DataRRow) striing sttrid = e.Roow.Cellls0.Textt;/獲取取第一行的字字段值; e.Roow.Cellls3.Attrributees.Addd(OnCClick, reeturn confiirm(確認(rèn)刪除+sttrid+?); /用了了兩個轉(zhuǎn)義符符將第一列的的值用引號括括起來,注意意轉(zhuǎn)義符后面面一個將不被被解釋,是直直接放上去; ASP.NETT 程序中常常用的三十三三種代碼(11) 1.

11、打開新的的窗口并傳送送參數(shù):傳送參數(shù): respponse.writee(sccriptwindoow.opeen(*. HYPERLINK /article/4/ArticleList4_1.htm ASPx?iid=+tthis.DDropDoownLisst1.SeelectIIndex+&id11=+)/scrript) 接接收參數(shù): strinng a = Requuest.QQuerySStringg(id); sttring b = RRequesst.QueeryStrring(id1); 22.為按鈕添添加對話框 Buttoon1.Atttribuutes.AAdd(oonc

12、licck,rreturnn conffirm(確認(rèn)?); bbuttonn.attrributees.addd(oncclick,if(confiirm(aare yoou surre.?)rreturnn truee;elsseretturn ffalse;) 3.刪除除表格選定記記錄 intt intEEmpID = (innt)MyDDataGrrid.DaataKeyyse.IItem.IItemInndex; striing deeleteCCmd = DELEETE frrom Emmployeee wheere emmp_id = + intEEmpID.ToStrring()

13、 4.刪除表格記記錄警告prrivatee voidd DataaGrid_ItemCCreateed(Objject ssenderr,DataaGridIItemEvventArrgs e) swiitch(ee.Itemm.ItemmType) ccase LListIttemTyppe.Iteem : casee ListtItemTType.AAlternnatinggItem : ccase LListIttemTyppe.EdiitItemm: TableeCell myTabbleCelll; myTaableCeell = e.Iteem.Cellls144; LinkkBu

14、ttoon myDDeleteeButtoon ; myDDeleteeButtoon = (LinkBButtonn)myTaableCeell.Coontrolls0; mmyDeleeteButtton.AAttribbutes.Add(oncliick,returrn connfirm(您是否確確定要刪除這這條信息);); brreak; deffault: bbreak; 5.點擊表格行行鏈接另一頁頁privaate vooid grrdCusttomer_ItemDDataBoound(oobjectt sendder, SSystemm.Web.UI.WeebConttrols.

15、DataGGridIttemEveentArggs e) /點點擊表格打開開 if (e.Ittem.IttemTyppe = ListIItemTyype.Ittem e.Item.ItemTType = LisstItemmType.AlterrnatinngItemm) ee.Itemm.Attrributees.Addd(oncclick,winndow.oopen(Defauult.asspx?idd= + e.Iteem.Cellls0.Textt + );); 雙擊擊表格連接到到另一頁 在iteemDataaBind事事件中 iff(e.Ittem.IttemTyppe = Li

16、stIItemTyype.Ittem e.Item.ItemTType = LisstItemmType.AlterrnatinngItemm) strring OOrderIItemIDD =e.iitem.ccells1.Teext; . e.iteem.Atttributtes.Addd(onndblcllick, loccationn.hreff=./ShipppedGriid.asppx?id= + OOrderIItemIDD + ); ASP.NETT 程序中常常用的三十三三種代碼(22) 雙雙擊表格打開開新一頁 iif(e.IItem.IItemTyype = ListtIte

17、mTType.IItem ee.Itemm.ItemmType = LiistIteemTypee.AlteernatiingIteem) striing OrrderIttemID =e.ittem.ceells11.Texxt; ee.itemm.Attrributees.Addd(onddblcliick, openn(./ShipppedGriid.asppx?id= + OOrderIItemIDD + ); 6.表格格超連接列傳傳遞參數(shù)aasp:HyyperLiinkCollumn TTargett=_bllank headeertextt=ID號號 DattaTexttField

18、d=id NaviigateUUrl=aaaa.asspx?idd= %# DaataBinnder.EEval(CContaiiner.DDataIttem, 數(shù)據(jù)字段11)% & naame=%# DaataBinnder.EEval(CContaiiner.DDataIttem, 數(shù)據(jù)字段22)% / 7.表格格點擊改變顏顏色if (e.Iteem.IteemTypee = LListIttemTyppe.Iteem e.IItem.IItemTyype = ListtItemTType.AAlternnatinggItem) ee.Itemm.Attrributees.Addd(onc

19、click,thiis.styyle.baackgrooundCoolor=#99ccc00; thhis.sttyle.ccolor=butttontexxt;thhis.sttyle.ccursorr=deffault;); 寫在在DataGGrid的_ItemDDataBoound里 if (ee.Itemm.ItemmType = LiistIteemTypee.Itemm e.Ittem.IttemTyppe = ListIItemTyype.AllternaatingIItem) e.IItem.AAttribbutes.Add(onmouuseoveer,tthis.sstyle

20、.backggrounddColorr=#999cc00; tthis.sstyle.colorr=butttonteext;tthis.sstyle.cursoor=deefaultt;); e.Ittem.Atttribuutes.AAdd(oonmousseout,thiis.styyle.baackgrooundCoolor=;thiis.styyle.coolor=;); 8.關(guān)關(guān)于日期格式式日期格格式設(shè)定 DDataFoormatSStringg=0:yyyy-MM-ddd 我覺得應(yīng)該該在itemmboundd事件中 ee.itemms.celll你的的列.ttext=DDateT

21、iime.Paarse(ee.itemms.celll你的的列.ttext.TToStriing(yyyyy-MMM-dd) 9.獲取錯錯誤信息并到到指定頁面不要使用用Respoonse.RRedireect,而應(yīng)應(yīng)該使用Seerver.Transsfer e.g / inn globbal.assax prrotectted vooid Appplicaation_Errorr(Objeect seender, EvenntArgss e) if (Serveer.GettLastEError() is HttpUUnhanddledExxceptiion) SServerr.Trannsf

22、er(MyErrrorPaage.asspx); /其余余的非HtttpUnhaandleddExcepption異異常交給ASSP.NETT自己處理就就okay了了 :) Reedirecct會導(dǎo)致ppostbback的產(chǎn)產(chǎn)生從而丟失失了錯誤信息息,所以頁面面導(dǎo)向應(yīng)該直直接在服務(wù)器器端執(zhí)行,這這樣就可以在在錯誤處理頁頁面得到出錯錯信息并進(jìn)行行相應(yīng)的處理理 100.清空CoookieASP.NETT 程序中常常用的三十三三種代碼(33) Cookiie.E HYPERLINK /article/44/ArticleList44_1.htm o XP經(jīng)驗技巧 XPPires=DateeTime;

23、 Ressponsee.Cookkies(UserNName).Expiires = 0 11.自定定義異常處理理/自定義義異常處理類類 usinng Sysstem; usingg Systtem.Diiagnossti HYPERLINK /soft/24862.htm o CS游戲下載 CS; nameespacee MyApppExceeptionn / ssummarry / 從系系統(tǒng)異常類AAppliccationnExcepption繼繼承的應(yīng)用程程序異常處理理類。 / 自動動將異常內(nèi)容容記錄到Wiindowss NT/ HYPERLINK /article/42/Article

24、List42_1.htm o Windows 2000技巧 22000的應(yīng)應(yīng)用程序日志志 / /suummaryy puublic classs AppEExcepttion:SSystemm.AppllicatiionExcceptioon pubblic AAppExcceptioon() if (AppliicatioonConffiguraation.EventtLogEnnabledd)LogEEvent(出現(xiàn)一個個未知錯誤。); puublic AppExxceptiion(sttring messaage) LLogEveent(meessagee); pubblic AAppE

25、xcceptioon(strring mmessagge,Excceptioon innnerExcceptioon) LoogEvennt(messsage); iif (innnerExxceptiion != nulll) LLogEveent(innnerExxceptiion.Meessagee); /日志志記錄類 usingg Systtem; usingg Systtem.Coonfiguuratioon; uusing Systeem.Diaagnosttics; usinng Sysstem.IIO; uusing Systeem.Texxt; uusing Systeem.

26、Thrreadinng; nnamesppace MMyEvenntLog / summaary / 事件日志記記錄類,提供供事件日志記記錄支持 / remaarks / 定義了44個日志記錄錄方法 (eerror, warnning, info, tracce) / /remaarks / /suummaryy ppublicc classs AppplicattionLoog / ssummarry / 將錯誤信息息記錄到Wiin20000/NT事件件日志中 / parram naame=mmessagge需要要記錄的文本本信息/pparam / /summaary pubblic sst

27、aticc voidd WritteErroor(Strring mmessagge) WriiteLogg(TracceLeveel.Errror, mmessagge); / summmary / 將警警告信息記錄錄到Win22000/NNT事件日志志中 / paramm namee=messsage需要記錄錄的文本信息息/parram / /suummaryy publiic staatic vvoid WWriteWWarninng(Strring mmessagge) WriiteLogg(TracceLeveel.Warrning, messsage); ASP.NETT 程序中常

28、常用的三十三三種代碼(44) / summaary / 將提示信信息記錄到WWin20000/NT事事件日志中 / paaram nname=messaage需需要記錄的文文本信息/paramm / /summmary puublic statiic voiid WriiteInffo(Strring mmessagge) WriiteLogg(TracceLeveel.Inffo, meessagee); / summmary / 將跟蹤蹤信息記錄到到Win20000/NTT事件日志中中 / pparam name=messsage需要記錄的的文本信息/paraam / /summmary

29、ppublicc stattic vooid WrriteTrrace(SStringg messsage) WWriteLLog(TrraceLeevel.VVerbosse, meessagee); / summmary / 格式化化記錄到事件件日志的文本本信息格式 / paaram nname=ex需需要格式化的的異常對象/paraam / paraam namme=caatchInnfo異異常信息標(biāo)題題字符串./paraam / retvvalue / ppara格格式后的異常常信息字符串串,包括異常常內(nèi)容和跟蹤蹤堆棧./para / /retvaalue / /ssummarry p

30、ubllic sttatic Strinng ForrmatExxceptiion(Exxceptiion exx, Strring ccatchIInfo) SStringgBuildder sttrBuillder = new StrinngBuillder(); if (catchhInfo != Sttring.Emptyy) sttrBuillder.AAppendd(catcchInfoo).Apppend(rn); sttrBuillder.AAppendd(ex.MMessagge).Apppend(rnn).Apppend(ex.SttackTrrace); returrn

31、strrBuildder.TooStrinng(); / suummaryy / 實實際事件日志志寫入方法 / paaram nname=levell要記錄錄信息的級別別(erroor,warrning,info,tracee)./pparam / pparam name=messsageTeext要要記錄的文本本./paaram / /ssummarry privvate sstaticc voidd WritteLog(TraceeLevell leveel, Sttring messaageTexxt) tryy EveentLoggEntryyType LogEnntryTyype;

32、sswitchh (levvel) casse TraaceLevvel.Errror: LoggEntryyType = EveentLoggEntryyType.Errorr; bbreak; casse TraaceLevvel.Waarningg: LLogEnttryTyppe = EEventLLogEnttryTyppe.Warrning; brreak; casee TracceLeveel.Inffo: LogEnntryTyype = EventtLogEnntryTyype.Innformaation; brreak; casee TracceLeveel.Verrbos

33、e: LoogEntrryTypee = EvventLoogEntrryTypee.S HYPERLINK /soft/24977.htm o 新浪UC下載 UCcesssAuditt;ASP.NETT 程序中常常用的三十三三種代碼(55) bbreak; deffault: LoogEntrryTypee = EvventLoogEntrryTypee.SucccessAuudit; breeak; EvenntLog eventtLog = new EventtLog(Appliicatioon, AAppliccationnConfiigurattion.EEventLLogMacch

34、ineNName, AppliicatioonConffiguraation.EventtLogSoourceNName ); /寫寫入事件日志志 evenntLog.WriteeEntryy(messsageTeext, LLogEnttryTyppe); caatch /忽忽略任何異常常 /classs AppllicatiionLogg 12.PPanel 橫向滾動,縱縱向自動擴(kuò)展展asp:panell stylle=ovverfloow-x:sscrolll;overrflow-y:autto;/asp:panell 113.回車轉(zhuǎn)轉(zhuǎn)換成Tabbscriipt laanguagge=

35、HYPERLINK /article/239/ArticleList239_1.htm o Java技巧 Jaavascrript for=documment eventt=onkkeydowwn if(evvent.kkeyCodde=133 & eevent.srcEllementt.typee!=buutton & eevent.srcEllementt.typee!=suubmit & evvent.ssrcEleement.type!=resset & eveent.srrcElemment.ttype!=& eventt.srcEElemennt.typpe!=ttextarrea

36、); eevent.keyCoode=9; /sccript onkeeydownn=if(eventt.keyCCode=13) eevent.keyCoode=9 144.DataaGrid超超級連接列aataNavvigateeUrlFiield=字段名 DataNNavigaateUrllFormaatStriing=hhttp:/xx/iinc/deelete.aspx?ID=00 15.DaataGriid行隨鼠標(biāo)標(biāo)變色priivate void DGzf_ItemDDataBoound(oobjectt sendder, SSystemm.Web.UI.WeebConttrols

37、.DataGGridIttemEveentArggs e) if (e.Ittem.IttemTyppe!=LiistIteemTypee.Headder) e.Item.Attriibutess.Add( onmmouseoout,this.stylee.backkgrounndColoor=+e.Ittem.SttyleBACKGGROUNDD-COLOOR+); e.Item.Attriibutess.Add( onmmouseoover,thiss.stylle.bacckgrouundCollor=+ #EFF3FF7+); 166.模板列ASP:TTEMPLAATECOLLUMN

38、vvisiblle=Faalse sorteexpresssion=demoo heaaderteext=IID ITEMTTEMPLAATE ASP:LLABEL text=%# DataBBinderr.Evall(Conttainerr.DataaItem, ArtticleIID)% runnat=sserverr widdth=880% iid=lbblColuumn / /IITEMTEEMPLATTE ASP.NETT 程序中常常用的三十三三種代碼(66) /AASP:TEEMPLATTECOLUUMN ASP:TTEMPLAATECOLLUMN hheaderrtext=選中

39、HEAADERSTTYLE wwrap=Falsee horrizonttalaliign=CCenterr/HHEADERRSTYLEE ITTEMTEMMPLATEE ASSP:CHEECKBOXX id=chkExxport runaat=seerver / /ITEMMTEMPLLATE EDITTITEMTTEMPLAATE ASP:CCHECKBBOX idd=chkkExporrtON runatt=serrver enablled=ttrue / /EDITIITEMTEEMPLATTE /ASP:TTEMPLAATECOLLUMN 后臺代代碼 prootecteed voii

40、d CheeckAlll_ChecckedChhangedd(objeect seender, Systtem.EvventArrgs e) /改改變列的選定定,實現(xiàn)全選選或全不選。 ChecckBox chkExxport ; iff( CheeckAlll.Checcked) fforeacch(DattaGriddItem oDataaGridIItem iin MyDDataGrrid.Ittems) chkEExportt = (CCheckBBox)oDDataGrridIteem.FinndConttrol(chkExxport); chkEExportt.Checcked =

41、truee; ellse fooreachh(DataaGridIItem ooDataGGridIttem inn MyDaataGriid.Iteems) chkEExportt = (CCheckBBox)oDDataGrridIteem.FinndConttrol(chkExxport); chkEExportt.Checcked = falsse; 17.數(shù)字格式化化【%#Conttainerr.DataaItem(pricce)%的結(jié)果是5500.00000,怎樣樣格式化為5500.000?】 %#Conttainerr.DataaItem(pricce,0:¥#,#0.000)%

42、 intt i=1223456; striing s=i.ToSStringg(#,#.00); 18.日日期格式化 【asspx頁面內(nèi)內(nèi):%# DataBBinderr.Evall(Conttainerr.DataaItem,Comppany_UUreg_DDate)% 顯顯示為: 22004-88-11 119:44:28 我只想要:2004-8-11 】 %# DataaBindeer.Evaal(Conntaineer.DattaItemm,Commpany_Ureg_Date,0:yyyy-M-d)% 應(yīng)該如何何改? 【格式化日日期】 取出來,一一般是objject(DateTTim

43、e)oobjecttFromDDB).TooStrinng(yyyyy-MMM-dd); 【日日期的驗證表表達(dá)式】 A.以下下正確的輸入入格式: 2004-2-29, 20004-022-29 110:29:39 pmm, 22004/112/31 (d2(0244680048)(135779266)-/ss?(0?113578)(1002)-/s?(0?1-9)(1-20-9)(3011)(0?469)(11)-/s?(0?11-9)(1-20-9)(30)(0?2-/s?(0?1-9)(1-220-99)(d2(02468812335679)(133579013455789)-/s?(00

44、?135578)(102)-/s?(0?1-9)(1-20-9)(3301)(0?4669)(111)-/ss?(00?1-99)(11-200-9)(30)(0?2-/s?(0?1-9)(110-9)(200-8)(s(0?1-9)(110-2):(0-50-9)(ss)(:(0-50-9)s)(AMPPMampmm2,22)?$ ASP.NETT 程序中常常用的三十三三種代碼(77) BB.以下正確確的輸入格式式:00001-12-31, 99999 09 330, 2002/03/033 d4-/s?(0135578)(102)-/s?(00-200-9)(301)(04669)(111

45、)-/ss?(0-20-9)(30)(02-/s?00-200-9)$ 【大大小寫轉(zhuǎn)換】 HttpUUtilitty.HtmmlEncoode(sttring); HtttpUtillity.HHtmlDeecode(strinng) 19.如何何設(shè)定全局變變量Gllobal.asax中中 Appplicaation_Startt()事件中中 添加加Appliicatioon屬性名名 xxxx; 就是你的的全局變量 20.怎怎樣作到HyyperLiinkCollumn生成成的連接后,點點擊連接,打打開新窗口?HypperLinnkColuumn有個屬屬性Targget,將器器值設(shè)置成_blan

46、nk即可.(Targget=_blankk) 【AASPNETTMENU】點點擊菜單項彈彈出新窗口 在你的的menuDData. HYPERLINK /article/203/ArticleList203_1.htm o XML技巧 XXML文件的的菜單項中加加入URLTTargett=_bllank,如如: ?xxml veersionn=1.00 enccodingg=GB22312? MeenuDatta ImaagesBaaseURLL=imaages/ MeenuGrooup MenuIItem LLabel=內(nèi)參信息息 URLL=Inffomatiion.asspx MennuGr

47、ouup ID=BBC MeenuIteem Labbel=公公告信息 URL=Infommationn.aspxx URLLTargeet=_bblank LefttIcon=filee.gif/ MMenuIttem Laabel=編制信息簡簡報 URRL=NeewInfoo.aspxx LefftIconn=fille.giff / 最最好將你的aaspnettmenu升升級到1.22版 221.讀取DDataGrrid控件TTextBoox值forreach(DataGGrid ddgi inn yourrDataGGrid.IItems) TexxtBox tb = (TexttBo

48、x)ddgi.FiindConntrol(yourrTextBBoxId); ttb.Texxt 233.在DattaGridd中有3個模模板列包含TTextboox分別為 DG_ShhuLianng (數(shù)量量) DG_DanJiian(單價價) DG_JinE(金額)分別別在5.6.7列,要求求在錄入數(shù)量量及單價的時時候自動算出出金額即:數(shù)數(shù)量*單價=金額還要求求錄入時限制制為數(shù)值型.我如何用客客戶端腳本實實現(xiàn)這個功能能? 思?xì)w asp:TTemplaateCollumn HHeaderrText=數(shù)量 IteemTempplate aspp:TexttBox iid=ShhuLianng

49、ruunat=serveer Teext=%# DaataBinnder.EEval(CContaiiner.DDataIttem,DDG_ShuuLiangg)% onkeeyup=javasscriptt:DoCaal() / assp:ReggularEExpresssionVValidaator iid=reevS rrunat=servver CControolToVaalidatte=ShhuLianng ErrrorMeessagee=musst be integger VValidaationEExpresssion=d+$ / /IttemTemmplatee /aasp:T

50、eemplatteColuumn asp:TTemplaateCollumn HHeaderrText=單價 ASP.NETT 程序中常常用的三十三三種代碼(88) IttemTemmplatee assp:TexxtBox id=DDanJiaan ruunat=serveer Teext=%# DaataBinnder.EEval(CContaiiner.DDataIttem,DDG_DannJian)% onkeyyup=jjavasccript:DoCall() / assp:ReggularEExpresssionVValidaator iid=reevS2 runatt=serrv

51、er ContrrolToVValidaate=DDanJiaan ErrrorMeessagee=musst be numerric VValidaationEExpresssion=d+(.dd*)?$ / /ItemmTempllate /aspp:TempplateCColumnn assp:TemmplateeColummn HeaaderTeext=金金額 ItemTTemplaate asp:TTextBoox id=JinEE runnat=sserverr Texxt=%# DattaBindder.Evval(Coontainner.DaataIteem,DGG_JinEE

52、)% / /ItemmTempllate /aspp:TempplateCColumnnscrript llanguaage=jjavasccript funnctionn DoCaal() varr e = eventt.srcEElemennt; vvar roow = ee.pareentNodde.parrentNoode; var ttxts = row.all.ttags(INPUTT); if (!txts.lengtth txtts.lenngth 3) retuurn; var qq = txxtstxxts.leength-3.vaalue; var p = ttxtstt

53、xts.llengthh-2.vvalue; if (isNaaN(q) isNaNN(p) retturn; q = parseeInt(qq); pp = paarseFlloat(pp); ttxtsttxts.llengthh-1.vvalue = (q * p).toFixxed(2); /sccript 24.ddatagrrid選定比比較底下的行行時,為什么么總是刷新一一下,然后就就滾動到了最最上面,剛才才選定的行因因屏幕的關(guān)系系就看不到了了。pagee_loadd pagee.smarrtNaviigatioon=truue 25.在在Dataggrid中修修改數(shù)據(jù),當(dāng)當(dāng)點擊編

54、輯鍵鍵時,數(shù)據(jù)出出現(xiàn)在文本框框中,怎么控控制文本框的的大小 ? privaate vooid DaataGriid1_IttemDattaBounnd(objj sendder,DaataGriidItemmEventtArgs e) for(int ii=0;ie.Iteem.Cellls.Coount-11;i+) iff(e.Ittem.IttemTyppe=LiistIteemTypee.EdittType) e.Item.Cellssi.AAttribbutes.Add(Widthh, 880px) 266.對話框pprivatte staatic sstringg ScriiptB

55、eggin = scrript llanguaage=JavaSScriptt; privvate sstaticc striing SccriptEEnd = /sccript; puublic statiic voiid ConnfirmMMessaggeBox(strinng PaggeTargget,sttring Conteent) strring CConfirrmConttent=var rretVallue=wiindow.confiirm(+Conttent+);+if(rretVallue)wwindoww.locaation=+PaageTarrget+; Connfir

56、mCContennt=ScrriptBeegin + ConffirmCoontentt + SccriptEEnd;ASP.NETT 程序中常常用的三十三三種代碼(99) Pagee ParaameterrPage = (Paage)Syystem.Web.HHttpCoontextt.Currrent.HHandleer; PParameeterPaage.ReegisteerStarrtupSccript(conffirm,ConfiirmConntent); /Respoonse.WWrite(strSccript); 27. 將時間格格式化:sttring aa=DaateTimme

57、.Noww.ToSttring(yyyyy年MM月ddd日); 1.1 取當(dāng)前前年月日時分分秒 currrentTTime=SSystemm.DateeTime.Now; 1.22 取當(dāng)前年年 int 年= DaateTimme.Noww.Yearr; 11.3 取當(dāng)當(dāng)前月 innt 月= DateTTime.NNow.Moonth; 1.44 取當(dāng)前日日 int 日= DaateTimme.Noww.Day; 1.5 取當(dāng)前前時 intt 時= DDateTiime.Noow.Houur; 1.6 取取當(dāng)前分 iint 分= DateeTime.Now.MMinutee; 11.7 取當(dāng)當(dāng)前

58、秒 innt 秒= DateTTime.NNow.Seecond; 1.8 取當(dāng)前前毫秒 innt 毫秒= DateeTime.Now.MMillissecondd; 228自定義義分頁代碼: 先定定義變量 : publlic sttatic int ppageCoount; /總頁面面數(shù) pubblic sstaticc int curPaageInddex=1; /當(dāng)前前頁面 下一頁: if(DaataGriid1.CuurrenttPageIIndex (DaataGriid1.PaageCouunt - 1) DattaGridd1.CurrrentPPageInndex += 1;

59、curPPageInndex+=1; bind(); / DataaGrid11數(shù)據(jù)綁定函函數(shù) 上上一頁: iif(DattaGridd1.CurrrentPPageInndex 0) DataaGrid11.CurrrentPaageInddex += 1; curPaageInddex-=11; bindd(); / DattaGridd1數(shù)據(jù)綁定定函數(shù) 直接頁面跳跳轉(zhuǎn): innt a=iint.Paarse(JJumpPaage.Vaalue.TTrim();/JJumpPaage.Vaalue.TTrim()為跳轉(zhuǎn)值 if(aDataGGrid1.PageCCount) thiis.D

60、attaGridd1.CurrrentPPageInndex=aa; bindd(); 229DattaGridd使用:添加刪除確確認(rèn): prrivatee voidd DataaGrid11_ItemmCreatted(obbject sendeer, Syystem.Web.UUI.WebbContrrols.DDataGrridIteemEvenntArgss e) forreach(DataGGridIttem dii in tthis.DDataGrrid1.IItems) f(ddi.IteemTypee=LisstItemmType.Itemddi.IteemTypee=Liss

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論