日期:2014-05-17  浏览次数:20408 次

没多少分。大家能帮一下帮吗?gridview添加按钮获取选中的ID
本帖最后由 hard171730 于 2013-06-25 15:26:09 编辑






如何获取ID 。?网上4了很多方法都不行,不知道是我的问题,还是百度问题!

在这里求如何单击按钮时获取,单机这一行的ID,

大恩不言谢。

ID列已经隐藏

------解决方案--------------------
<a  class="btnselect" onclick="var top=(window.parent.screen.height-500)/2-20;var left=(window.parent.screen.width-800)/2;window.open('NewsDetail.aspx?id=<%#Eval("id") %>','newwindow','height=500,width=800,top='+top+',left='+left+',toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')" href="javascript:void(0);">查看</a>
------解决方案--------------------
    
<asp:Button ID="btn1" runat="server" Text="Button" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>' OnCommand="btn1_Command"/>

用这个事件 OnCommand 

//这个可以当成点击事件来用
 protected void btn1_Command(object sender, CommandEventArgs e)
        {
            string id = e.CommandArgument.ToString();
        }

------解决方案--------------------
if you want get row index, can refer this:


http://www.cnblogs.com/insus/archive/2013/01/13/2858768.html