熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

DataGrid Web Control 基本操作

2022-06-13   來源: Java核心技術 

  dgCategory是用於顯示類別表的DataGrid
  
  自動分頁AllowPaging= TRUE!!!!
  
  private void dgCategory_PageIndexChanged(object source SystemWebUIWebControlsDataGridPageChangedEventArgs e)
  
  {
  
  dgCategoryCurrentPageIndex=eNewPageIndex
  
  dgCategoryDataBind()
  
  }
  
  排序默認按PKId排序
  
  private void dgCategory_SortCommand(object source SystemWebUIWebControlsDataGridSortCommandEventArgs e)
  
  {
  
  string SortOrder=eSortExpressionToString()
  
  BindData(SortOrder)
  
  }
  
  private void BindData(string SortOrder)
  
  {
  
  ProductSystem productSys=new ProductSystem()//底層數據接口
  
  CategoryData categorySet=productSysGetCategories( //底層數據接口返回ID為的Category
  
  DataView   categoryView=categorySetTables[CategoryDataCATEGORIES_TABLE]DefaultView
  
  categoryViewSort=SortOrder
  
  lblTitleText=+SortOrder+排序
  
  dgCategoryDataSource=categoryView
  
  dgCategoryDataBind()
  
  }
  
  private void Page_Load(object sender SystemEventArgs e)
  
  {
  
  BindData(PKId
  
  }
  
  編輯更新取消
  
  private void dgCategory_EditCommand(object source SystemWebUIWebControlsDataGridCommandEventArgs e)
  
  {
  
  dgCategoryEditItemIndex=eItemItemIndex
  
  BindData(PKId
  
  }
  
  private void dgCategory_CancelCommand(object source SystemWebUIWebControlsDataGridCommandEventArgs e)
  
  {
  
  dgCategoryEditItemIndex=
  
  BindData(PKId
  
  }
  
  private void dgCategory_UpdateCommand(object source SystemWebUIWebControlsDataGridCommandEventArgs e)
  
  {
  
  string strUpdate=
  
  strUpdate+=PKId=+((TextBox)eItemCells[]Controls[])Text+
  
  strUpdate+=ParentId=+((TextBox)eItemCells[]Controls[])Text+
  
  strUpdate+=Description=+((TextBox)eItemCells[]Controls[])Text+
  
  strUpdate+=IsLeaf=+((TextBox)eItemCells[]Controls[])Text+
  
  try
  
  {
  
  CagegorySetExecuteUpdate(strUpdate)//需要後台提供更新的接口
  
  dgCategoryEditItemIndex=
  
  }
  
  catch
  
  {
  
  ResponseWrite(<script language=javascript>alert(未能完成更新請…………)</script>
  
  }
  
  BindData(PKId
  
  }
  
  private void dgCategory_DeleteCommand(object source SystemWebUIWebControlsDataGridCommandEventArgs e)
  
  {
  
  //獲得關鍵字使用DataKeys集合訪問數據列表控件中每個記錄的鍵值(顯示為一行)
  
  //使得用戶可以存儲鍵字段而無需在控件中顯示它
  
  string PKId=dgCategoryDataKeys[eItemItemIndex]
  
  CategorySetExecuteDelete(PKId)
  
  }*/
From:http://tw.wingwit.com/Article/program/Java/hx/201311/27145.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.