1
我有一個ASP.NET的GridView與DropDownList(在項目模板)和ButtonField。如何從Buttonfield單擊中獲取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指向)設置爲下拉列表中的值。請注意,該行不會處於更新模式。
在此先感謝!
Tom
有趣。我認爲這是一個由按鈕的參數設置的值,而不是行索引。這是默認的嗎? – 2009-01-23 17:17:43