0
동적 인 TemplateField가있는 RadGrid가있는 사용자 컨트롤이 있습니다. 동적 인 것처럼 ITemplate에서 상속 한 고유 한 사용자 지정 클래스를 사용하고 있습니다. 아래 코드 :페이지/컨트롤을 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 클래스의 컨텍스트에서 만들어져 사용자 컨트롤의 컨트롤에 액세스 할 수 없다는 것입니다. 내가 할 수있는 방법이 있니?
그게 좋겠지 만 대신 사용자 컨트롤 개체를 가져와야하므로 작동하지 않습니다. 예 : 아래 : 응용 프로그램 app = (응용 프로그램) ((제어) 보낸 사람) .Page; 은에 유형 'System.Web.UI.Page을'변환 할 수 없습니다 나에게 을 준다 'Project.JobControls.Applications' – Chris
그래서'Project.JobControls.Applications'는'UserControl'이'TextBox'가에 앉아 있다는 것입니다? '(Project.JobControls.Applications) txt.NamingContainer;를 시도하십시오. –
그래, 여기가 텍스트 상자가 상주하며 원하는 메소드가 들어 있습니다. – Chris