文章分类 | 推荐文章 | 最新文章 | 热点文章 | 最新软件 | 精品软件 | 下载排行 | 推荐下载 | 免费看大片 | WPS | 杀毒软件
清风网络
首 页 软件下载 网络学院 数码学院
QQ 电脑入门 游戏 操作系统 图形处理 办公软件 媒体动画 精文荟萃 工具软件 网络编程 程序开发 网络技术 认证考试 网站建设 文章专栏
当前位置:清风网络学院网络编程Asp.NetDataGrid常见关注问题解决方案
精品推荐
特别推荐
·技巧实例:ASP.NET生成静态页面实现方法
·ASP.NET、JSP及PHP之间的抉择
·.net基础知识错误注意二十二点知识
·asp.net2.0学习历程 菜鸟到中级程序员的飞跃
·.NET基础知识-什么是.NET
·初学C#+ASP.NET+Oracle时积累的备忘点滴
·专家详解:复杂表达式的执行步骤
·asp.net中的加密方法
·DataGrid常见关注问题解决方案
·学习笔记 ASP.NET 5种页面转向法
·ASP.NET网络编程中经常会用到的27个函数集
·ASP.NET之上传文件管理策略
·专家:用.NET动态创建类的实例讲解
·ASP.NET WEB服务和Flash打造MP3播放器
·精通ASP.NET中弹出窗口技术
·asp.net常用代码
·asp.net创建文件夹的IO类的问题
·Asp.Net函数集
·Asp.net cache 简述
·如何最大限度提高.NET的性能 (续)
热点TOP10
·DataTable控件的使用
·ASP.NET上传文件的实例
·ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!
·asp.net(C#)海量数据表高效率分页算法(易懂,不使用存储过程)
·ASP.NET购物车的实现及结算处理
·在ASP.NET中防止注入攻击[翻译]
·使用ASP.NET2.0的ReportViewer查看RDLC报表
·asp.net程序中最常用的三十三种编程代码
·ASP.NET 2.0的导航控件treeview和menu的实例
·asp.net常用代码
·Lucene.net 实现全文搜索
·在C#后代码里使用IE WEB Control TreeView
·asp.net2.0学习历程 菜鸟到中级程序员的飞跃
·Access 通用数据访问类(asp.net 2.0 c#)
·.Net分页控件发布
·ASP.NET之上传文件管理策略
·AspNetPager分页控件--使用方法
·asp.net 2.0中gridview里嵌套dropdownlist
·手把手教你在Win2003下配置ASP.NET开发环境
·ASP.net在线购物商城系统完全解析

DataGrid常见关注问题解决方案

日期:2007年7月15日 作者:清风网络学院 查看:[大字体 中字体 小字体]


DropDownList ddl =
(DropDownList) e.Item.FindControl("DropDownList1");
ddl.SelectedIndex =
ddl.Items.IndexOf(ddl.Items.FindByText(currentgenre));
}
}
Selecting Multiple Items Using a Check Box (Hotmail Model)
In applications such as Microsoft Hotmail®, users can "select" rows by checking a box and then performing an operation on all the selected rows — for example, delete them or copy them.

To add functionality like this, add a template column to the grid and put a check box into the column. When the page runs, users will be able to check the items they want to work with.

To actually perform the user action, you can walk the grid's Items collection, looking into the appropriate column (cell) to see if the check box is checked. The following example shows how you can delete rows in a dataset corresponding to the items that a user has checked. The dataset, called dsBooks1, is assumed to contain a table called Books.

' Visual Basic
Private Sub btnDelete_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnDelete.Click
' Walk the grid looking for selected rows
Dim i As Integer = 0
Dim cb As CheckBox
Dim dgi As DataGridItem
Dim bookid As Integer
Dim dr As dsBooks.BooksRow
For Each dgi In DataGrid1.Items
cb = CType(dgi.Cells(0).Controls(1), CheckBox)
If cb.Checked Then
' Determine the key of the selected record ...
bookid = CType(DataGrid1.DataKeys(i), Integer)
' ... get a pointer to the corresponding dataset record ...
dr = Me.DsBooks1.Books.FindBybookid(bookid)
' ... and delete it.
dr.Delete()
End If
i += 1
Next
Me.SqlDataAdapter1.Update(DsBooks1)
Me.SqlDataAdapter1.Fill(DsBooks1)
DataGrid1.DataBind()
End Sub

// C#
private void btnDelete_Click(object sender, System.EventArgs e)
{
int i = 0;
CheckBox cb;
int bookid;
dsBooks.BooksRow dr;
foreach(DataGridItem dgi in this.DataGrid1.Items)
{
cb = (CheckBox) dgi.Cells[0].Controls[1];
if(cb.Checked)
{
// Determine the key of the selected record ...
bookid = (int) DataGrid1.DataKeys[i];
// ... get a pointer to the corresponding dataset record ...
dr = this.dsBooks1.Books.FindBybookid(bookid);
// ... and delete it.
dr.Delete();
}
i++;
}
this.sqlDataAdapter1.Update(this.dsBooks1);
this.sqlDataAdapter1.Fill(this.dsBooks1);
DataGrid1.DataBind();

上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] 下一页 




上一篇:自己写的一个简单ASP调用存储过程查询

下一篇:使用ASP与JAVASCRIPT配合实现多个复选框数据关联显示

DataGrid常见关注问题解决方案 相关文章:
·XP系统运行慢?小编自用7招解决
·《边看边打赚大奖--迅雷宽频》部分问题及答案
·不用重装XP系统就可以解决全部故障
·校园网组建方案
·施工与工程组织方案
·全面解决Generic host process for win32 services遇到问题需要关闭
·经典常见计算机密码破解实用手册
·[综合]召唤兽常见技能资质表(最新修补完整版)
·国内大学校园网网络建设方案参考
·外挂 录象 网站 举报方案最新教程_QQ堂
DataGrid常见关注问题解决方案 相关软件:
·网络常见问题与故障1000例
·成功少儿培养方案(上中下)高清晰PDF电子书
·有关毛泽东的一些问题解答(不完整版)
·中东问题的历史根源
·每天问自己十个问题
·动网先锋系统集成方案大全
·《常见皮肤性病诊断与治疗》
·生命问题
·百度知道 1850个经典问题
·SmartGrid表格控件 for Asp.Net(Web Grid,DataGrid) V2.0 For VS2005

特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
[打印本页] [关闭窗口] 转载请注明来源:http://www.viphot.com
| 帮助(?) | 版权声明 | 友情连接 | 关于我们 | 信息发布
Copyright 2007 www.viphot.com All Rights Reserved. 鄂ICP备05000083号Powered by:viphot