Gridview里buttonField值如何读取

[复制链接]
查看11 | 回复4 | 2011-3-27 11:48:05 | 显示全部楼层 |阅读模式
我在Gridview里,有一列设置成buttonField,然后我想点击的时候,能读取出我点击的那个按钮的值。
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string a = (我点击的那个按钮的值);

回复

使用道具 举报

千问 | 2011-3-27 11:48:05 | 显示全部楼层
<pre id=\"best-answer-content\" class=\"reply-text mb10\">将buttonField转换成模板列,然后设置它的CommandArgument就行了。

前台代码:
asp:TemplateField ShowHeader=\"False\"

ItemTemplate

asp:Button ID=\"Button1\" runat=\"server\" CausesValidation=\"False\"

CommandArgument=\'%# Eval(\"字段名\") %\' Text=\'%# Eval(\"字段名\") %\' /

/ItemTemplate

/asp:TemplateField

后台代码:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)

{
string a=e.CommandArgument.ToString();


}
回复

使用道具 举报

千问 | 2011-3-27 11:48:05 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-2339865\">???
回复

使用道具 举报

千问 | 2011-3-27 11:48:05 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-2339984\">Gridview里,buttonField,然后我想点击的时候在点protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
回复

使用道具 举报

千问 | 2011-3-27 11:48:05 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-2341841\">?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行