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"的值.
查看全文
相关阅读:
【转】Math.Atan2 方法
【转】Excel快捷键大全
Tricks(四十七)—— 布尔矩阵(0-1矩阵)取反
Tricks(四十七)—— 布尔矩阵(0-1矩阵)取反
tensorflow 函数接口的理解
tensorflow 函数接口的理解
TensorFlow 学习(十一)—— 正则(regularizer)
TensorFlow 学习(十一)—— 正则(regularizer)
TensorFlow 需注意的细节问题
TensorFlow 需注意的细节问题
原文地址:https://www.cnblogs.com/cnaspnet/p/669410.html
最新文章
我也谈“the difference between Factory, Service, and Provider in Angular”
javascript event bubbling and capturing (再谈一谈js的事件冒泡和事件补获,看到这篇文章加深了理解)
HDU 4886 TIANKENG’s restaurant(Ⅱ) hash+dfs
hdu 1244 DP
ACM-最短路(SPFA,Dijkstra,Floyd)之最短路——hdu2544
Linux音频驱动简述
[leetcode]Remove Duplicates from Sorted Array II
B. Suffix Structures 模拟吧,情况比較多要想周全
C语言-对一个结构体中的字段进行排序
leetcoder-50-Pow(x, n)
热门文章
xpages开发的bom管理系统
一支巧乐兹引发的感想(这个标题实在没有创意)
[转]Ubuntu Linux 安装 .7z 解压和压缩文件
[转]ubuntu14.04安装好用的google拼音输入法
【转】快速删除大文件夹
【转】Android中定时器的3种实现方法
【转】Date类学习总结(Calendar Date 字符串 相互转换 格式化)
【转】使用DateFormat把时间长度格式化为"时:分:秒"格式--不错
【转】Android 定时器实现的几种方式和removeCallbacks失效问题详解--不错
【转】Java.Math API 反正切算角度(四个象限情况要调整)
Copyright © 2011-2022 走看看