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

Reading number is top 10 articles
PHP日期时间函数的高级应用技巧_php资料_编程技术
SQL Server2005数字转中文大写字母_[SQL Server教程]
精通数据库系列之入门-技巧篇5_mssql学习_编程技术
Delphi变量、类、对象、函数规范化命名
ADO.NET数据库实例教程_[Asp.Net教程]
SQL,SERVER中一些对象的名称更改_[SQL,Server教程]
《Effective,C#》-使用成员初始化语句_.net资料_编程技术
入门知识:动态网页PHP编程中字符串5个技巧_[PHP教程]
ASP.NET,2.0+Atlas编写鼠标拖放程序_.net资料_编程技术
追踪ASP.NET代码里的bug_[Asp.Net教程]
Reading number is top 10 pictures
宝贝系列
A man's favorite things10
China railway shunting skills competition
Sell the barbecue as says father du breul2
全球清廉国家排行
The money of more than 100 countries and regions11
The money of more than 100 countries and regions1
Get girl by your hand
Sora aoi mirror memorial classics4
Born After 90 Beijing sports university campus flower photos4
Download software ranking
Tram sex maniac 2 (H) rar bag6
Proficient in Eclipse
星际争霸1.08硬盘免安装版
C#编程思想
软件工程思想
Red cliff
matrix3
Sora aoi - one of more PK
Take off clothes to survival
VC++6.0简体中文版
归海一刀 published in(发表于) 2014/1/30 1:35:00 Edit(编辑)
将DataGrid中的列显示或隐藏_[Asp.Net教程]

将DataGrid中的列显示或隐藏_[Asp.Net教程]

将DataGrid中的列显示或隐藏_[Asp.Net教程]

显示和隐藏DataGrid中的列,主要是将AutoGenerateColumns设置为False:下面就是实现这一功能的ASPx文件和脚本代码:

<%@ Page Language="VB" AutoEventWireup="false" Codebehind="ShowHideCols.ASPx.vb"
Inherits="aspxWeb.ShowHideCols"%>



ShowHideCols
.net 7.0">

JavaScript">






BorderColor="#999999" BorderStyle="None" BorderWidth="1px" BackColor="White"
CellPadding="3" GridLines="Vertical">



Visible="False" />










后台代码:

Imports System.Data
Imports System.Data.OleDb

Public Class ShowHideCols
Inherits System.Web.UI.Page
Protected WithEvents btnShow As System.Web.UI.WebControls.Button
Protected WithEvents btnHide As System.Web.UI.WebControls.Button
Protected WithEvents dtgCusts As System.Web.UI.WebControls.DataGrid

#Region " Web 窗体设计器生成的代码 "

’该调用是 Web 窗体设计器所必需的。
Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Init
’CODEGEN: 此方法调用是 Web 窗体设计器所必需的
’不要使用代码编辑器修改它。
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Load
’在此处放置初始化页的用户代码
btnShow.Text = "显示列"
btnHide.Text = "隐藏列"
dtgCusts.Columns(1).HeaderText = ""
dtgCusts.Columns(0).HeaderText = "标题"
dtgCusts.Columns(2).HeaderText = "发布日期"
dtgCusts.Columns(3).HeaderText = "编辑"
If Not IsPostBack Then
BindTheData()
End If
End Sub

Sub BindTheData()
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
objConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
+ Server.MapPath("Test.mdb"))
Dim strSql As String
strSql = "SELECT Top 10 id,Title,CreateDate FROM Document"
objCmd = New OleDbCommand(strSql, objConn)
objConn.Open()
dtgCusts.DataSource = objCmd.ExecuteReader()
dtgCusts.DataBind()
objConn.Close()
objConn.Dispose()
End Sub
Sub ShowDetails(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim intCounter As Integer
For intCounter = 1 To dtgCusts.Columns.Count - 1
dtgCusts.Columns(intCounter).Visible = True
Next
End Sub

Sub HideDetails(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim intCounter As Integer
For intCounter = 1 To dtgCusts.Columns.Count - 1
dtgCusts.Columns(intCounter).Visible = False
Next
End Sub

End Class




添加到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.