gridview获取选中行索引及当前行数据

gridview获取选中行索引及当前行数据

一.非直接绑定数据:


"操作"> "lbtnDelete" runat="server" CommandName="CustomDelete" CommandArgument="<%# Container.DataItemIndex) %>>" OnClientClick="javascript:return confirm('真的要删除吗?');">删除 "lbtnEdit" runat="server" CommandName="CustomUpdate" CommandArgument="<%# Container.DataItemIndex %>">编辑

 

//后台获取
 int index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row = GridView1.Rows[index];

二.绑定数据:


"LinkButton1" runat="server" CommandArgument='<%# Eval("Id") %>' CommandName="tt">删除

 

//后台获取Id值
string id = e.CommandArgument.ToString();

 

转载于:https://www.cnblogs.com/zlp520/p/10770727.html

你可能感兴趣的:(gridview获取选中行索引及当前行数据)