###前提・実現したいこと
GridView上のボタン押下で編集モードへ移行した後
別のボタン押下で編集中のテキストの値を参照したい
[手順]
1.ボタンB押下(対象行を編集モードへ移行)
2.BoundField の値を編集
3.ボタンC押下(ここで編集中のBoundField の値を確認したい※元の値はいらない)
###該当のソースコード
aspx
1<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_RowCommand"> 2 <Columns> 3 <asp:BoundField DataField="A" HeaderText="A"></asp:BoundField> 4 <asp:ButtonField Text="ボタン" CommandName="B"></asp:ButtonField> 5 <asp:ButtonField Text="ボタン" CommandName="C"></asp:ButtonField> 6 </Columns> 7 </asp:GridView>
C#
1protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 2 { 3 int args = Int32.Parse((String)e.CommandArgument); 4 5 switch (e.CommandName) 6 { 7 //実績修正 8 case "B": 9 GridView1.EditIndex = args; 10 GridView1.bind(); 11 break; 12 case "C": 13 //ここで編集中のテキストを参照したい 14 break; 15 }
###試したこと
GridView1.Rows[args].Cells[n].Textでは参照できませんでした。
###補足情報(言語/FW/ツール等のバージョンなど)
ドットネットフレームワーク4.5.2
C#
webform
回答1件
あなたの回答
tips
プレビュー