zoukankan
html css js c++ java
一个GridView编辑删除的例子
aspx:
<
asp:GridView
ID
="myGvClass"
runat
="server"
AutoGenerateColumns
="False"
Width
="100%"
DataKeyNames
="id"
OnRowCancelingEdit
="myGvClass_RowCancelingEdit"
OnRowEditing
="myGvClass_RowEditing"
OnRowUpdating
="myGvClass_RowUpdating"
OnRowDeleting
="myGvClass_RowDeleting"
BorderColor
="#CCCCCC"
BorderStyle
="Solid"
BorderWidth
="1px"
>
<
Columns
>
<
asp:BoundField
DataField
="id"
HeaderText
="序号"
ReadOnly
="True"
>
<
ItemStyle
HorizontalAlign
="Center"
/>
<
HeaderStyle
HorizontalAlign
="Center"
Width
="10%"
/></
asp:BoundField
>
<
asp:BoundField
DataField
="classname"
HeaderText
="栏目名称"
>
<
ItemStyle
HorizontalAlign
="Left"
/>
<
HeaderStyle
HorizontalAlign
="Left"
Width
="52%"
/>
<
ControlStyle
Width
="80%"
/>
</
asp:BoundField
>
<
asp:BoundField
DataField
="stime"
HeaderText
="操作时间"
ReadOnly
="True"
>
<
ItemStyle
HorizontalAlign
="Center"
/>
<
HeaderStyle
HorizontalAlign
="Center"
Width
="20%"
/></
asp:BoundField
>
<
asp:CommandField
HeaderText
="操作"
ShowEditButton
="True"
>
<
HeaderStyle
HorizontalAlign
="Center"
Width
="12%"
/>
<
ItemStyle
HorizontalAlign
="Center"
/></
asp:CommandField
>
<
asp:TemplateField
HeaderText
="删除"
ShowHeader
="False"
>
<
ItemStyle
HorizontalAlign
="Center"
/>
<
HeaderStyle
HorizontalAlign
="Center"
Width
="6%"
/>
<
ItemTemplate
>
<
asp:LinkButton
ID
="LinkButton1"
OnClientClick
="return confirm('您确认删除该记录吗?');"
runat
="server"
CausesValidation
="False"
CommandName
="Delete"
Text
="删除"
></
asp:LinkButton
>
</
ItemTemplate
>
</
asp:TemplateField
>
</
Columns
>
<
HeaderStyle
BackColor
="LightGray"
/>
</
asp:GridView
>
CS:
protected
void
myGvClass_RowEditing(
object
sender, GridViewEditEventArgs e)
{
myGvClass.EditIndex
=
e.NewEditIndex;
this
.myGvClass.EditRowStyle.BackColor
=
Color.AliceBlue;
BinData();
}
protected
void
myGvClass_RowCancelingEdit(
object
sender, GridViewCancelEditEventArgs e)
{
myGvClass.EditIndex
=
-
1
;
BinData();
}
protected
void
myGvClass_RowUpdating(
object
sender, GridViewUpdateEventArgs e)
{
string
strID
=
this
.myGvClass.DataKeys[e.RowIndex].Value.ToString();
string
strClassName
=
((TextBox)(myGvClass.Rows[e.RowIndex].Cells[
1
].Controls[
0
])).Text.Trim().ToString();
WebClass.ArticleList tmp
=
new
WebClass.ArticleList();
tmp.EditClass(strClassName,strID);
myGvClass.EditIndex
=
-
1
;
BinData();
}
protected
void
myGvClass_RowDeleting(
object
sender, GridViewDeleteEventArgs e)
{
string
strID
=
this
.myGvClass.DataKeys[e.RowIndex].Value.ToString();
WebClass.ArticleList tmp
=
new
WebClass.ArticleList();
tmp.DelClass(strID);
myGvClass.EditIndex
=
-
1
;
BinData();
}
查看全文
相关阅读:
【RxJava Demo分析】(二)Schedulers线程调度器 · Hans Zone
Docker Swarm和Kubernetes在大规模集群中的性能比较
Linux用户组的添加及属性的更改
SurfaceView和TextureView的区别
吴裕雄--天生自然 R语言开发学习:使用键盘、带分隔符的文本文件输入数据
吴裕雄--天生自然 高等数学学习:区间
吴裕雄--天生自然 R语言开发学习:数据集和数据结构
吴裕雄--天生自然 R语言开发学习:R语言的简单介绍和使用
吴裕雄--天生自然 高等数学学习:前言
吴裕雄--天生自然 R语言开发学习:基础知识
原文地址:https://www.cnblogs.com/cnaspnet/p/937607.html
最新文章
09-了解23张表
08-使用自动建表(默认配置)
07-使用框架提供的自动建表(没有提供配置文件)
【收藏】前端知识体系完整版本
21个ui设计技巧,让你的设计不落伍
21个ui设计技巧,让你的设计不落伍
21个ui设计技巧,让你的设计不落伍
JavaScript框架的超简史
JavaScript框架的超简史
JavaScript框架的超简史
热门文章
收集一些常用的前端知识
收集一些常用的前端知识
收集一些常用的前端知识
printdir-deldir-bmp
用jekyll和github把网站建起来!
傲世九重天 第三百三十六章 又一次突破
跨域资源共享 CORS 详解(转)
《和莎莫的 500 天》中为什么 Summer 最终没有和 Tom 在一起?
前端开发个人小结 · Retrospection的博客
resourcequota分析(一)-evaluator-v1.5.2
Copyright © 2011-2022 走看看