0

動的な TemplateField を持つ RadGrid を持つユーザー コントロールがあります。それらは動的であるため、ITemplate から継承する独自のカスタム クラスを使用しています。以下のコード:

    public class ApplicationHeaderTemplateItem : ITemplate
    {
        private string colName;
        public ApplicationHeaderTemplateItem(string cName)
        {
            colName = cName;
        }

        public void InstantiateIn(Control container)
        {

            HtmlTable tb = new HtmlTable();
        HtmlTableRow headerRow = new HtmlTableRow();


        //Create the textbox to display the percentage
        HtmlTableCell percentCell = new HtmlTableCell();
        RadNumericTextBox txt = new RadNumericTextBox();
        txt.ID = "txt" + colName;
        txt.DataBinding += txt_DataBinding;
        txt.AutoPostBack = true;
        txt.TextChanged += txt_TextChanged;
        percentCell.Controls.Add(txt);
        headerRow.Cells.Add(percentCell);

         --snip--
        }

        void txt_TextChanged(object sender, EventArgs e)
        {

        }

    }

ご覧のとおり、テキストボックスに TextChanged イベントがあります。私の問題は、メソッドが ApplicationHeaderTemplateItem クラスのコンテキストで作成されるため、ユーザー コントロール内のどのコントロールにもアクセスできないことです。これを行う方法はありますか?

4

1 に答える 1

0

sender引数を使用してを取得すると、すべてのコントロールにプロパティTextBoxがあるため、既にそこにいます。Page

void txt_TextChanged(object sender, EventArgs e)
{
    Control txt = (Control) sender;
    Page page = txt.Page;
}
于 2013-08-29T13:39:14.880 に答える