惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
MyScale Blog
MyScale Blog
Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 叶小钗
博客园 - 聂微东
U
Unit 42
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
IT之家
IT之家
The GitHub Blog
The GitHub Blog
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)

博客园 - 神话

C#的float型,竟然与SQL中float型不对应(转载) 【源码】非常有用的Vml图像画板(收藏) 为Html 的Select 加一个提示语和输入方法(转载) asp.net三色交替的下拉列表框(转载) 常用正则表达式(收藏) ListBox控件上移、下移操作(Ajax) 客户端实现PadLeft 日历控件收藏 我的博客地图脚本代码 实时统计输入字符数 我的博客地图特效 生成html页面 初次使用ZedGraph 梅花雪日历控件(网络收藏) 树型菜单<仿QQ型菜单>(网络收藏) 面向对象分析(网络收藏) 常用正则表达式(收集)及使用方法 三层架构(非原创) 网页常用代码小技巧五(网络收藏)
获取某行的字段ID值(GridView模板列)
神话 · 2007-06-15 · via 博客园 - 神话

aspx页面

<asp:GridView runat="server" ID="grd" AutoGenerateColumns="false" DataKeyNames="leagueID" OnRowCommand="grd_RowCommand"  OnRowCreated="grd_RowCreated">
<Columns>
<asp:TemplateField HeaderText="我要加入">
                    
<ItemStyle HorizontalAlign="Center" />
                    
<ItemTemplate>
                        
&nbsp;<asp:Button runat="server" ID="btnJoin" Text="加 入" CommandName="btnJoin" />
                    
</ItemTemplate>
                 
</asp:TemplateField>
</Columns>
</asp:GridView>

aspx.cs类文件

 protected void grd_RowCommand(object sender, GridViewCommandEventArgs e)
    
{
        
if (e.CommandName == "btnJoin")
        
{
                
int index = Data.GetInt(e.CommandArgument);
                
int iLeagueID = Data.GetInt(grd.DataKeys[index].Value);
                Response.Write(
"<script>alert('" + iLeagueID + "')</script>");
        }

    }


    
protected void grd_RowCreated(object sender, GridViewRowEventArgs e)
    
{
        
if (e.Row.RowType == DataControlRowType.DataRow)
        
{
                Button btnJoin 
= (Button)e.Row.FindControl("btnJoin");
                btnJoin.CommandArgument 
= e.Row.RowIndex.ToString();
        }

    }