如何从Buttonfield单击获取GridView的当前行?

时间:2009-01-23 17:05:23

标签: c# asp.net gridview

我有一个带有DropDownList(在项模板中)和ButtonField的ASP.NET GridView。

<my:GridView AutoGenerateColumns="false" ID="CurrentCardGrid" UseHighlights="False" runat="server" Width="100%">
 <Columns>
  <asp:BoundField HeaderText="ID" ItemStyle-Width="50px" DataField="Id" />
  <asp:TemplateField HeaderText="" ItemStyle-Width="150px">
   <ItemTemplate>
    <asp:DropDownList runat="server" ID="StatusList" Width="140px">
    </asp:DropDownList>
   </ItemTemplate>
  </asp:TemplateField>
  <asp:ButtonField Text="Update" ButtonType="Button" CommandName="Update" />
 </Columns>
</my:GridView>

在代码中,我填写下拉列表并捕获RowCommand事件。

我的问题是,在RowCommand事件处理程序中,如何获取当前行?我需要从下拉列表中获取值,并将行的状态(由ID指向)设置为下拉列表中的值。请注意,该行不会处于更新模式。

提前致谢!

汤姆

1 个答案:

答案 0 :(得分:2)

将e.CommandArgument转换为事件处理程序中的int。

来自here

相关问题