私はこのような何かを試みたが、うまくいきませんでした:GridView RowCommandイベントのコントロールを見つけるには?
GridViewRow row = (GridViewRow)(((Repeater)e.CommandSource).NamingContainer);
Repeater _rpt1 = row.Cells[8].FindControl("rptReg") as Repeater;
はエラー:
Unable to cast object of type 'System.Web.UI.WebControls.Button' to type 'System.Web.UI.WebControls.Repeater'.
私はGridViewコントロールを使用してOnRowCommand
イベントに以下のコードを持つことができる方法はありますか?あなたの誤差がある
実際に私は、GridViewコントロールから行を削除しようとしているとするとき、ユーザーがクリックその上、私はmulitple IDをつかみ、SPに渡していますし、テーブルとdatabind the gridview
GridViewRow row = gv.SelectedRow;
Repeater _rpt = gv.Rows[e.RowIndex].Cells[8].FindControl("rptReg") as Repeater;
Repeater _rpt1 = gv.Rows[e.RowIndex].Cells[9].FindControl("rptVisitor") as Repeater;
foreach (RepeaterItem item in _rpt.Items)
{
TextBox _txt = item.FindControl("txtId") as TextBox;
TextBox _txt1 = item.FindControl("txtName") as TextBox;
//update db
}
私はわかりません次のようにOnRowCommandでe.CommandName == "delete"を確認することができます – Malk
thats正しいが、私はRowCommandでFindControlを行う方法を探している状況がありますか? –
リピータがヌルになると思いますか?多分yoyはgvを "Gridview gv =(Gridview)sender;"と定義するべきです – Malk