###前提・実現したいこと
CommandFieldボタンを利用した更新処理で
一行目は正常に更新できるが
2行目以降の更新ボタン押下時のイベントが発生しない(ブレークポイントで確認)
※一行目はRowCommandイベントもRowUpdatingも発生する。
[実現したい操作]
1.page_loadでbind
2.修正押下で編集モードへ移行
3.Aの値を編集
4.更新ボタンで更新
[2行目を指定した時の挙動]
2.修正押下で編集モードへ移行
3.Aの値を編集
4.更新ボタンで更新できない
RowCommandイベントもRowUpdatingも発生していない
(取消ボタンのほうはRowCancelingEditとRowCommandが発生して正常に動作する)
###aspx
<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_RowCommand" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit"> <Columns> <asp:BoundField DataField="A" HeaderText="A"></asp:BoundField> <asp:CommandField ButtonType="Button" ShowEditButton="true" EditText="修正" CancelText="取消" UpdateText="更新" ></asp:CommandField> <asp:ButtonField Text="ボタン" CommandName="B"></asp:ButtonField> <asp:ButtonField Text="ボタン" CommandName="C"></asp:ButtonField> <asp:BoundField DataField="D" HeaderText="D" visible=false></asp:BoundField> </Columns> </asp:GridView>
###page_load
page_load
1//sqlcmd : sqlcommand コネクションおよびコマンドテキスト入力済み 2DataSet datas = new DataSet(); 3 using (SqlDataAdapter adapt = new SqlDataAdapter()) 4 { 5 adapt.SelectCommand = sqlcmd; 6 adapt.Fill(datas); 7 } 8 9 GridView1.DataSource = datas; 10 GridView1.DataBind(); 11
###補足情報(言語/FW/ツール等のバージョンなど)
ドットネットフレームワーク4.5.2
C#
Webform
sqldatasource等はaspxファイルに設置していない
回答1件
あなたの回答
tips
プレビュー