All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
delphi组件VCL类库结构
ASP.NET中文件上传下载方法集合_[Asp.Net教程]
C#教程:POP3与SMTP协议使用实例
在atlas里面的UpdatePanel控件中调用javascript,以及updatePanel的_[Asp.Net教程]
用PHP自动把纯文本转换成Web页面_[PHP教程]
PHP+MySQL应用中使用XOR运算加密算法_php资料_编程技术
PHP连接MYSQL的两种方法_php资料_编程技术
.Net,Framework3.0,实践纪实之布局_[Asp.Net教程]
visit c++中Connection与Recordset
C#中ImageAnimator类功能和方法
Reading number is top 10 pictures
Absolutely shocked. National geographic 50 animal photographys6
Black and white also sexy--YanLiu2
身材野火台灣美女1
So beauty, will let you spray blood5
Li Zongrui hunting video screenshots1
Sora aoi possession photo2
避免防盗门的猫眼变成钥匙眼
The money of more than 100 countries and regions2
A man's favorite things7
Fury xp desktop theme
Download software ranking
apache-tomcat-6.0.33
Tram sex maniac 2 (H) rar bag15
Sora aoi, the maid, students' uniforms
Jinling thirteen stock
Tram sex maniac 2 (H) rar bag1
美女写真2
Sora aoi‘s film--Lust fan wall
金山office2007
Unix video tutorial2
Love the forty days
delv published in(发表于) 2014/1/27 6:47:37 Edit(编辑)
ASP.NET2.0中GridView控件的隐藏列的问题_[Asp.Net教程]

ASP.NET2.0中GridView控件的隐藏列的问题_[Asp.Net教程]

ASP.NET2.0中GridView控件的隐藏列的问题_[Asp.Net教程]

  Asp.net2.0GridView隐藏列visible="false" 后你就无法取得这列的值了, 而用datagrid就没有这个问题, MS这个混蛋老是改变游戏规则, 幸好我聪明, 在百度上搜到了别人的解决方法, 然后加入了自己的方法, 才解决问题:


  protected void GVList_RowDataBound(object sender, GridViewRowEventArgs e)
  {
  //隐藏不必要的列
  if ((e.Row.RowType == DataControlRowType.DataRow) || (e.Row.RowType == DataControlRowType.Header) || (e.Row.RowType == DataControlRowType.Footer))
  {
  e.Row.Cells[0].Visible = false;
  e.Row.Cells[3].Visible = false;
  }
  }


  这是迄今为止最简洁的解决方法了。


  解决方案


  在RowCreated事件中书写如下代码:


  void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
  {
  if (e.Row.RowType == DataControlRowType.DataRow ||
  e.Row.RowType == DataControlRowType.Header)
  {
  e.Row.Cells[0].Visible = false; //如果想使第1列不可见,则将它的可见性设为false
  }
  //可以根据需要设置更多的列
  }


  因为在RowCreated事件(隐藏)在绑定时候发生,所以这样就即能将数据绑定到列上,又隐藏了该列.所以可以访问到隐藏列的值。


  下面介绍另外一个可以将数据绑定到GridView控件的方法:


Public void myTestFunction()
  {
  string conString="....";//省略
  string sqlquery="...";//省略
  SqlConnection con = new SqlConnection(conString);
  SqlDataAdapter da = new SqlDataAdapter(sqlquery, con);
  DataSet ds = new DataSet();
  da.Fill(ds);
  ds.Tables[0].Columns[0].ColumnMapping = MappingType.Hidden;
  GridView1.DataSouce = ds.Tables[0];
  GridView1.DataBind() ;
  }


  文章主要讲述了ASP.NET2.0中GridView控件的隐藏列的问题.







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.