zoukankan
html css js c++ java
GridView中的RowCommand事件
也是在这次项目开发遇到的问题,本来放在一起的,后来发现太长了,所有就分开来写.
不过都是一些非常简单的问题,怕忘记,在这里作一个记录.
GridView模版列中Button取值问题:
<
asp:GridView
ID
="GridView1"
runat
="server"
DataKeyNames
="id"
AutoGenerateColumns
="False"
ShowHeader
="False"
Width
="100%"
OnRowDataBound
="GridView1_RowDataBound"
OnRowCommand
="GridView1_RowCommand"
>
<
Columns
>
<
asp:BoundField
DataField
="dept"
>
<
ItemStyle
Height
="20px"
Width
="10%"
HorizontalAlign
="Center"
/>
</
asp:BoundField
>
<
asp:BoundField
DataField
="deptnm"
>
<
ItemStyle
Width
="15%"
/>
</
asp:BoundField
>
<
asp:TemplateField
>
<
ItemTemplate
>
意见:
<
asp:TextBox
CssClass
="inputLine"
ID
="txtNotion"
runat
="server"
Width
="300px"
></
asp:TextBox
>
</
ItemTemplate
>
<
ItemStyle
Width
="40%"
/>
</
asp:TemplateField
>
<
asp:TemplateField
>
<
ItemTemplate
>
<
asp:HiddenField
ID
="hditem"
runat
="server"
Value
='<%#
Eval("item") %
>
' />
<
asp:RadioButtonList
ID
="rblidea"
runat
="server"
RepeatDirection
="Horizontal"
RepeatLayout
="Flow"
>
<
asp:ListItem
Value
="1"
>
同意
</
asp:ListItem
>
<
asp:ListItem
Value
="0"
>
不同意
</
asp:ListItem
>
</
asp:RadioButtonList
>
</
ItemTemplate
>
<
ItemStyle
HorizontalAlign
="Center"
Width
="20%"
/>
</
asp:TemplateField
>
<
asp:TemplateField
>
<
ItemTemplate
>
<
asp:Button
ID
="btnSubVise"
CommandName
="vise"
CommandArgument
='<%#
Eval("id") %
>
' runat="server" Text="提 交" CssClass="Sub_button2" />
<
input
id
="ReSubVise"
type
="reset"
value
="重 置"
class
="Sub_button2"
runat
="server"
/>
</
ItemTemplate
>
<
ItemStyle
HorizontalAlign
="Center"
Width
="15%"
/>
</
asp:TemplateField
>
</
Columns
>
</
asp:GridView
>
点击"提交"这个按钮,想取得"意见"这个TextBox的值.
protected
void
GridView1_RowCommand(
object
sender, GridViewCommandEventArgs e)
{
GridViewRow row
=
((Control)e.CommandSource).BindingContainer
as
GridViewRow;
int
index
=
row.RowIndex;
string
strid
=
e.CommandArgument.ToString();
if
(e.CommandName
==
"
vise
"
)
{
string
strid
=
GridView1.DataKeys[index].Value.ToString();
TextBox txtNotion
=
(TextBox)row.FindControl(
"
txtNotion
"
);
Response.Write(txtNotion.Text.ToString());
}
}
e.CommandArgument是取CommandArgument='<%# Eval("id") %>'的值.index是取GridView中DataKeyNames="id"的值.
查看全文
相关阅读:
java中的HMAC-SHA1加密
java拦截处理System.exit(0)
使用canal分析binlog(二) canal源码分析
JS的异步世界
socket.io的用户认证
一个补零小函数
使用gulp在开发过程中合理导出zip文件
使用r.js进行前端repuirejs的合并压缩
使用r2d3的注意事项
三列自适应布局的实现方式(兼容IE6+)
原文地址:https://www.cnblogs.com/cnaspnet/p/669410.html
最新文章
Java基础的坑
mybatis <where>标签别勿用,否则线上清表
windowsserver的应用升级部署坑
tomcat更新class不生效
mybatis: Invalid bound statement (not found)即使调试源码也很难注意的坑
lombok与spring的恩怨
万恶的mysql deadlocks
Aborted connection+druid
mysql问题总结
游戏开发相关教程资料整理
热门文章
记一次Java项目死锁问题的排查思路
Memory Analyzer (MAT) 启动报错解决
定制个性化的博客模板
分享自己的博客模板
使用maven构建和打包项目、使用私有仓库Nexus中遇到的问题和解决方案
Java字符串拼接、数字转换字符串性能测试与优化方案
SpringBoot启动报错:Failed to introspect Class [org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@4e0e2f2a]
spring探秘:通过BeanPostProcessor、@PostConstruct、InitializingBean在启动前执行方法
解决Linux执行cp命令提示 cp: overwrite xxx
java使用单例与使用static方法的对于和个人理解
Copyright © 2011-2022 走看看