GridView 行号值得获取

1、asp:ButtonField模板中的行号获取

 前台代码:<asp:ButtonField ButtonType="Button" Text="" CommandName="lookyx" />

后台代码:if (e.CommandName == "lookcq")
        {
            int index = Int32.Parse(e.CommandArgument.ToString());
            string autobh = GridView1.DataKeys[index].Values[""].ToString();

}

2、TemplateFiled模板中的行号获取

前台代码:

<asp:TemplateField>
            <ItemTemplate><asp:LinkButton ID="Button3" CommandName="zhuxiao" runat="server" Text="" OnClientClick="return confirm('')"  CommandArgument='<%#Eval("BH") %>'/>
            </ItemTemplate>
            <ItemStyle Width="60"/>
            </asp:TemplateField>

后台:

if (e.CommandName == "zhuxiao")
        {
            string bh = e.CommandArgument.ToString();
        }

 

posted @ 2013-05-27 08:57  Bluze  阅读(293)  评论(0编辑  收藏  举报