私は、いくつかのダイナミックコントロールをSimpleQueryControlに追加しようとしています(Webコントロールの一種であり、それに応じてすべてのメソッドを継承します)。私は動的に追加した子コントロールの値を取得する方法を知らない。動的に追加されたコントロールのID(およびもちろん値)を取得できません
class RoomPickerQueryControl : SimpleQueryControl
{
protected override void OnLoad(EventArgs e)
{
if (!Page.IsPostBack)
{
EnsureChildControls();
mColumnList.Visible = false;
}
}
protected override void OnInit(EventArgs e)
{
DateTimeControl controlStartDate = new DateTimeControl();
controlStartDate.LocaleId = 1053;
controlStartDate.CssClassTextBox = "ms-long";
controlStartDate.TimeZoneID = 1053;
controlStartDate.LocaleId = 1053;
controlStartDate.MinDate = DateTime.Now;
controlStartDate.ID = "startDateTime";
controlStartDate.Visible = true;
controlStartDate.Enabled = true;
controlStartDate.EnableViewState = true;
this.Controls.Add(controlStartDate);
base.OnInit(e);
}
protected override void CreateChildControls()
{
base.CreateChildControls();
}
protected override int IssueQuery(string search, string groupName, int pageIndex, int pageSize)
{
//i'm unable to get the ids here
DateTimeControl dt = (DateTimeControl) FindControlRecursive(this, "startDateTime");
//i'm unable to get the ids here
DateTimeControl dt3 = (DateTimeControl)FindControlRecursive(this.Page, "startDateTime");
//i'm unable to get the ids here
DateTimeControl controlStartDate = (DateTimeControl)this.FindControl("startDateTime");
//i'm unable to get the ids here
DateTimeControl controlEndDate = (DateTimeControl)this.FindControl("endDateTime");
return rowCount;
}
public static Control FindControlRecursive(Control Root, string Id)
{
if (Root.ID == Id)
return Root;
foreach (Control Ctl in Root.Controls)
{
Control FoundCtl = FindControlRecursive(Ctl, Id);
if (FoundCtl != null)
return FoundCtl;
}
return null;
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
}
}
どのようにこの値を使用しますか? – EvgK
IssueQueryメソッドでDateTimeControlの値を使用します。 –
あなたの解決策を提供してください。あなたはそれらのIDとそのコントロールを解決しようとしています – Luke