ASPNET五大数据控件ptp.docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《ASPNET五大数据控件ptp.docx》由会员分享,可在线阅读,更多相关《ASPNET五大数据控件ptp.docx(29页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Evaluation Warning: The document was created with Spire.Doc for .NET.数据绑定控控件比较 (ReaapterrDattaLisstGrridViiewDDataiilsViiewFFormVView):1.插入功功能方面:DetaiilsViiew和FFormVView具具有插入功功能,其它它控件没有有2.模板DataLListFormmViewwReppeateer三种必必须编辑模模板,而GridVView和和DetaailsVView只只有在将列列转换成模模板列以后后才会出现现各种模板板.3.自动分分页功能GridVVie
2、w ,DettailssVieww和ForrmVieew都是22.0版本本新增控件件,内置了了分页,排排序等等功功能,其他需要手手工定义4.数据呈呈现方式:GridVView,DataaListt,Reppeatoor用于呈呈现多列数数据,DetaiilsViiew,FFormVView用用于呈现单单列数据,即常用的的数据明细细. DataLList和和Reappter都都需要编辑辑模板列,而而在模板列列当中可以以添加TeextBoox,同时时可以指定定TexttBox的的ID从而而实现提取取用户输入入的值,但但是DattaGriid和GrridViiew两个个件是不需需要编辑模模板的,它它的
3、编辑功功能是自动动生成的我我们无法知知道那些文文本框的IID,也就就无法通过过ID来获获取用户的的输入,那那么可以通通过对单元元格的引用用来实现:privaate vvoid DataaGridd1_UppdateeCommmand(objeect ssourcce,xxx) sstrinng bkkid=DDataGGrid11.DattaKeyyse.Itemm.IteemInddex.toSttringg();/提取主主键 sstrinng bkktitlle=(TexttBox)e.Ittem.CCellss1.Conttrolss0).Texxt;/提取用户户的输入一.进入编编辑状态
4、:DataLList11.EdiitIteemInddex = e.IItem.ItemmIndeex;DataGGrid11.EdiitIteemInddex = e.IItem.ItemmIndeex;GridVView11.EdiitInddex = e.NNewEdditInndex;DetaiilsViiew1.ChanngeMoode(DDetaiilsViiewMoode.EEdit);/进进入编辑状状态DetaiilsViiew1.ChanngeMoode(DDetaiilsViiewMoode.RReadOOnly);/退退出编辑状状态二.设置主主键:DataLList11.
5、DattaKeyyFielld = bkiid;DataGGrid11.DattaKeyyFielld = bkiid;strinng str=bkkid;GridVView11.DattaKeyyNamees = str;三.提取主主键:strinng bkkid = DattaLisst1.DDataKKeyse.Ittem.IItemIIndexx.TooStriing();/DDataLListstrinng bkkid = DattaGriid1.DDataKKeyse.Ittem.IItemIIndexx.TooStriing();/DDataGGridstrinng bkkid
6、= GriidVieew1.DDataKKeyse.RoowInddex.Valuue.TooStriing();/GGridVViewstrinng bkkid = DettailssVieww1.DaataKeey0.ToSStrinng();四.查找控控件:strinng bkktitlle = (TeextBoox)e.Itemm.FinndConntroll(txxtTille).Texxt;/DataaListtstrinng bkktitlle = (TeextBoox)e.Itemm.Cellls11.Coontrools00).TText;/DaataGrridstrinng
7、 bkktitlle = (TeextBoox)GrridViiew1.Rowsse.RRowInndex.Cellls11.Coontrools00).TText;strinng bkktitlle = (TeextBoox)DeetaillsVieew1.RRows1.CCellss1.Conttrolss0).Texxt;注意查找控控件有两种种方法:(各数据绑绑定控件的的都可以用用下面两种种方法进行行查找)1.如果知知道控件的的ID可以以用这种方方法(TexxtBoxx)e.IItem.FinddConttrol(txttTilee).Textt;/这这是查找2.如果不不知道控件件的ID
8、可可用这种方方法(TexxtBoxx)e.IItem.Cellls1.Conntrolls0).Teext;/这是索索引五.给删除除按钮添加加确认:proteectedd voiid DaataLiist1_ItemmDataaBounnd(obbjectt sennder, DattaLisstIteemEveentArrgs ee) if (e.Ittem.IItemTType = LListIItemTType.Itemm | e.Ittem.IItemTType = LListIItemTType.AlteernattingIItem) LinkkButtton llbtn =(Lii
9、nkBuuttonn) e.Itemm.FinndConntroll(lbbtndeeletee); lbtnn.Atttribuutes.Add(OnCClickk,rreturrn coonfirrm(确定要删删除吗?); proteectedd voiid DaataGrrid1_ItemmDataaBounnd(obbjectt sennder, DattaGriidIteemEveentArrgs ee) if(ee.Iteem.IttemTyype=ListtItemmTypee.Iteem | e.IItem.ItemmTypee=LiistIttemTyype.AAlterrn
10、atiingIttem) LinkkButtton llbtn = (LLinkBButtoon)e.Itemm.Cellls33.Coontrools00; lbtnn.Atttribuutes.Add(OnCClickk,rreturrn coonfirrm(确认删除除?); proteectedd voiid GrridViiew1_RowDDataBBoundd(objject sendder, GriddViewwRowEEventtArgss e) if(ee.Roww.RowwTypee= DDataCContrrolRoowTyppe.DaataRoow) striing ss
11、tridd = ee.Roww.Cellls00.Teext;/获取第第一行的字字段值; e.Roow.Ceells3.AAttriibutees.Addd(OOnCliick, reeturnn connfirmm(确认删除除+striid+?); /用了了两个转义义符将第一一列的值用用引号括起起来,注意意转义符后后面一个将将不被解释释,是直接接放上去; ASP.NNET 程程序中常用用的三十三三种代码(1) 1. 打打开新的窗窗口并传送送参数:传送参数数: reesponnse.wwritee(sscripptwiindoww.opeen(*.ASPPx?idd=+tthis.DroppD
12、ownnListt1.SeelecttIndeex+&id1=+.+)/sscrippt) 接接收参数: strring a = Requuest.QuerryStrring(id); sstrinng b = Reequesst.QuuerySStrinng(iid1); 2.为按按钮添加对对话框 BButtoon1.AAttriibutees.Addd(ooncliick,retturn conffirm(确认?); buuttonn.atttribuutes.add(oncclickk,iif(coonfirrm(aare yyou ssure.?)rreturrn trrue;else
13、eretturn falsse;) 3.删除除表格选定定记录 iint iintEmmpID = (iint)MMyDattaGriid.DaataKeeysee.Iteem.IttemInndex; sttringg delleteCCmd = DEELETEE froom Emmployyee wwheree empp_id = + inntEmppID.TToStrring() 4.删除除表格记录录警告prrivatte vooid DDataGGrid_ItemmCreaated(Objeect ssendeer,DaataGrridIttemEvventAArgs e) swwitc
14、hh(e.IItem.ItemmTypee) ccase ListtItemmTypee.Iteem : caase LListIItemTType.AlteernattingIItem : casee LisstIteemTyppe.EdditIttem: TTableeCelll myTTableeCelll; myTTableeCelll = ee.Iteem.Ceells14; LinkkButtton mmyDelleteBButtoon ; mmyDelleteBButtoon = (LinnkButtton)myTaableCCell.Conttrolss0; myDeelete
15、eButtton.AAttriibutees.Addd(ooncliick,retturn conffirm(您是否否确定要删删除这条信信息);); bbreakk; defaault: breaak; 5.点击表格格行链接另另一页prrivatte vooid ggrdCuustommer_IItemDDataBBoundd(objject sendder, Systtem.WWeb.UUI.WeebConntrolls.DaataGrridIttemEvventAArgs e) /点击表格格打开 if (e.Ittem.IItemTType = LListIItemTType.Itemm
16、e.IItem.ItemmTypee = ListtItemmTypee.AltternaatinggItemm) e.Ittem.AAttriibutees.Addd(ooncliick,winndow.openn(Deefaullt.asspx?iid= + e.Itemm.Cellls00.Teext + );); 双双击表格连连接到另一一页 在iteemDattaBinnd事件中中 if(e.Ittem.IItemTType = LListIItemTType.Itemm e.IItem.ItemmTypee = ListtItemmTypee.AltternaatinggItemm)
17、 sttringg OrdderIttemIDD =e.itemm.cellls11.Teext; . e.itemm.Atttribuutes.Add(onddblcllick, llocattion.hreff=./ShiippeddGridd.asppx?idd= + OrdderIttemIDD + ); ASP.NNET 程程序中常用用的三十三三种代码(2) 双双击表格打打开新一页页 if(e.Ittem.IItemTType = LListIItemTType.Itemm e.IItem.ItemmTypee = ListtItemmTypee.AltternaatinggItem
18、m) strring OrdeerIteemID =e.iitem.cellls1.Texxt; . e.iitem.Attrributtes.AAdd(ondbblcliick, oppen(./SShipppedGrrid.aaspx?id= + OOrderrItemmID + ); 6.表表格超连接接列传递参参数assp:HyyperLLinkCColummn Taargett=_bblankk heeaderrtextt=IDD号 DDataTTextFFieldd=idd NaavigaateUrrl=aaaa.aaspx?id= %# DaataBiinderr.Evaal(Co
19、ontaiiner.DataaItemm, 数数据字段11)% & namee=%# DaataBiinderr.Evaal(Coontaiiner.DataaItemm, 数数据字段22)% / 77.表格点点击改变颜颜色if (e.IItem.ItemmTypee = ListtItemmTypee.Iteem e.Itemm.IteemTyppe = LisstIteemTyppe.AllternnatinngIteem) e.Itemm.Atttribuutes.Add(oncclickk,tthis.stylle.baackgrrounddColoor=#99ccc00; thiss
20、.styyle.ccolorr=buuttonntextt;thhis.sstylee.currsor=deffaultt;); 写在在DataaGridd的_IttemDaataBoound里里 if (e.IItem.ItemmTypee = ListtItemmTypee.Iteem e.Itemm.IteemTyppe = LisstIteemTyppe.AllternnatinngIteem) e.IItem.Attrributtes.AAdd(onmoouseoover,thhis.sstylee.bacckgrooundCColorr=#999cc000; tthis.styll
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ASPNET 数据 控件 ptp
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内