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"的值.
查看全文
相关阅读:
使用vs code开发.net core2.2时OmniSharp.MSBuild.ProjectLoader无法解析"xxx"的解决方法
An unexpected exception occurred while binding a dynamic operation 错误的一种情况
node excel export包导致find函数被覆盖
C#字典Dictionay多线程读是否是安全的
mongodb数据分组按字符串split
IIS做反向代理重定向到NodeJS服务器
.net core 时间戳unix与本地时间互转、获取当前时间戳
使用Postman调试asp.net core 控制器的action
监听浏览器tab选项卡选中事件,点击浏览器tab标签页回调事件,浏览器tab切换监听事件
vue、element-ui开发技巧
原文地址:https://www.cnblogs.com/cnaspnet/p/669410.html
最新文章
绿色版Notepad++注册windows右键菜单
学习配置和使用 mysql 主从数据库
windows dia 无法输入中文
树莓派使用3.5mm 耳机口输出音频
arduino 连接ds18b20
Arduino连接L298n驱动板驱动小车的电机
使用obs 软件录屏和出现一些问题解决记录
Fiddler script 获取http响应和post的请求body数据
使用fiddler 软件监听手机app的http请求
php通过 curl方法请求下载 http链接文件
热门文章
php Call to undefined function ftp_connect()
Foobar 2000增加APE播放支持的方法
foobar2000 频谱给我的win10 任务栏添加一点会动背景
使用ubuntu的一些操作笔记20191203
cpanle/Apache 强制http跳转到https
Android的WebView调试工具(无需FanQ,可同时调试多个设备,永不过期)
如何使用H5的video实现全屏时横屏播放,手势上下滑动调节音量,左右滑动快进和后退
Google的Material Icons
仿简书MarkDown编辑器可同步滚动
超级简单,把PuppyLinux安装到U盘
Copyright © 2011-2022 走看看