c# - ASP.NET GridView RowIndex 作为 CommandArgument

标签 c# asp.net gridview

如何访问和显示 gridview 项的行索引作为按钮字段列按钮中的命令参数?

<gridview>
<Columns>
   <asp:ButtonField  ButtonType="Button" 
        CommandName="Edit" Text="Edit" Visible="True" 
        CommandArgument=" ? ? ? " />
.....

最佳答案

这里有一个非常简单的方法:

<asp:ButtonField ButtonType="Button" CommandName="Edit" Text="Edit" Visible="True" 
                 CommandArgument='<%# Container.DataItemIndex %>' />

关于c# - ASP.NET GridView RowIndex 作为 CommandArgument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/389403/

相关文章:

c# - GetSystemTimeZones() 的全局化

C# Gridview 复选框字段 VS(模板字段+复选框)

javascript - Check Box在gridview中以行索引方式被选中

c# - 在 C# 中优化尾调用

c# - 如何在 GridView 中的 ListViewItemPresenter 中更改 SelectedBackground

c# - .NET 单元测试 - 带有 MVC 的 Moq/xUnit 框架,未返回预期结果

c# - 调用 SysFreeString() 时出现堆损坏错误

asp.net - 具有多个验证组的页面始终为 Page.IsValid 返回 TRUE

c# - 选中 CheckBox 时如何添加整数值?

c# - OnRowDataBound点击事件打开另一个gridview