GridView动态绑定列

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

GridView动态绑定列在VS2005我们利用GridView的频率比较的大,但我们的数据列一般是不发生变化的,但在实际的工作中,我们需要对GridView的数据列进行修改,进行重新绑定,以下以进行动态绑定的代码,希望对您有所帮助,以下是HTML代码:%...@PageLanguage=C#AutoEventWireup=trueStylesheetTheme=DefaultTheme=DefaultCodeFile=Dictionary.aspx.csInherits=Admin_Dictionary%!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN==servertitle数据字典配置/title/headbodyformid=form1runat=serverfieldsetlegend菜单/legenddivid=tabsFulliahref=OfficeType.aspxtitle=办公用品类型span办公用品/span/a/liliahref=AddTax.aspxtitle=增值税税率数据字典span增值税税率/span/a/liliahref=MachineName.aspxtitle=整机机种,收款计划数据字典span整机机种|收款计划/span/a/liliahref=Default.aspxtitle=返回span返回/span/a/li/ul/div/fieldsetdivfieldsetlegend数据字典信息/legend tablewidth=100%trtdrowspan=2valign=topstyle=width:174pxfieldsetstyle=text-align:leftlegend数据字典项/legendasp:BulletedListID=blDataDictrunat=serverDisplayMode=LinkButtonOnClick=blDataDict_ClickBulletStyle=Squareasp:ListItemSelected=TrueValue=Dict_PayType付款类型/asp:ListItemasp:ListItemValue=Dict_PayModel付款方式/asp:ListItemasp:ListItemValue=Dict_IncType收款类型/asp:ListItemasp:ListItemValue=Dict_DeliveryModel交货方式/asp:ListItemasp:ListItemValue=Customer_Type客户类型/asp:ListItemasp:ListItemValue=Dict_TransModel运输方式/asp:ListItemasp:ListItemValue=Dict_MachineName整机名称/asp:ListItemasp:ListItemValue=Provider_Type供应商类型/asp:ListItemasp:ListItemValue=Dict_IncPlan_Kind收款性质类型/asp:ListItem/asp:BulletedList/fieldset/tdtdfieldsetlegend相关信息/legendasp:GridViewID=gvDictionarySkinID=Default_GridViewrunat=serverCaptionAlign=LeftOnRowCancelingEdit=gvDictionary_RowCancelingEditOnRowDataBound=gvDictionary_RowDataBoundOnRowEditing=gvDictionary_RowEditingOnRowUpdating=gvDictionary_RowUpdatingColumnsasp:BoundFieldDataField=DictNameHeaderText=字典名称/asp:BoundFieldasp:BoundFieldDataField=DictCodeHeaderText=字典编号ReadOnly=True/asp:BoundFieldasp:CheckBoxFieldDataField=IfUsingHeaderText=是否启用Text=启用/asp:CheckBoxFieldasp:BoundFieldDataField=NoteHeaderText=备注/asp:CommandFieldShowEditButton=TrueCausesValidation=False/asp:CommandField/Columns/asp:GridView/fieldset/td/trtrtdfieldsetlegend添加数据字典信息/legendbr/tablecellpadding=4id=tableInforunat=servertrtdalign=centercolspan=2asp:LabelID=lblTitlerunat=serverFont-Bold=True/asp:Label/td/trtrtdclass=tdbgspanstyle=color:#ff0000*/span数据字典编号:/tdtdalign=leftasp:TextBoxID=txtDictCoderunat=serverWidth=241px/asp:TextBoxasp:RequiredFieldValidatorID=RequiredFieldValidator1runat=serverControlToValidate=txtDictCodeErrorMessage=数据字典编号不能为空*/asp:RequiredFieldValidator/td/trtrtdclass=tdbgspanstyle=color:#ff0000*/span数据字典名称:/tdtdalign=leftasp:TextBoxID=txtDictNamerunat=serverWidth=241px/asp:TextBoxasp:RequiredFieldValidatorID=RequiredFieldValidator2runat=serverControlToValidate=txtDictNameErrorMessage=数据字典名称不能为空*/asp:RequiredFieldValidator/td/trtrtdclass=tdbg是否启用:/tdtdalign=leftasp:CheckBoxID=chkUsingrunat=serverText=启用Checked=True/asp:LabelID=lblTablerunat=serverVisible=False/asp:Label/td/trtrtdclass=tdbg备注:br//tdtdalign=leftasp:TextBoxID=txtNoterunat=serverHeight=60pxTextMode=MultiLineWidth=241px/asp:TextBox/td/trtrtdalign=centercolspan=2asp:ButtonID=btnSaverunat=serverText=保存OnClick=btnSave_Click/asp:ButtonID=btnCancelrunat=serverText=取消CausesValidation=FalseOnClick=btnCancel_Click/br/asp:LabelID=lblInforunat=server/asp:Label/td/tr/table/fieldset/td/tr/table/fieldsetfieldsetlegend业务逻辑/legendulli带spanstyle=color:red*/span项不能为空/li/ul/fieldset/divasp:ValidationSummaryID=ValidationSummary1runat=serverShowMessageBox=TrueShowSummary=False//form/body/html以上HTML,代码和普通的页面代码很相似,本页面完成的功能是,通过点击左边的链接,动态的调用,不同的表中的数据,但是,表中的字段名称,有的是不同的,因此需要我根据实际情况,进行动态绑定,以下页面代码:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;publicpartialclassAdmin_Dictionary:System.Web.UI.Page{//defineclassWebUtility.DictionaryBasedict=newWebUtility.DictionaryBase();protectedvoidPage_Load(objectsender,EventArgse){if(!Page.IsPostBack){//instantiationclassdict.DictionaryTableName=WebUtility.DictionaryBase.DictType.Dict_PayType.ToString();this.lblTable.Text=WebUtility.DictionaryBase.DictType.Dict_PayType.ToString();//setdatasourcethis.gvDictionary.Caption=付款类型+数据字典列表;this.lblTitle.Text=添加付款类型数据字典;this.gvDictionary.DataSource=dict.DataSetDictionary();this.gvDictionary.DataBind();}}protectedvoidblDataDict_Click(objectsender,BulletedListEventArgse){//setcaptionandtitlethis.gvDictionary.Caption=this.GetCaption(this.blDataDict.Items[e.Index].Text);this.lblTitle.Text=this.GetTitle(this.blDataDict

1 / 13
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功