0
WebユーザーコントロールでListItemCollectionを使用しました。そして私はそれが好きです!プレースホルダーのようにlistitemCollectionを使用するには
sample.asx
public ListItemCollection Items {
get {
return this.ListBox1.Items;
}
}
TestForSampleascx.aspx
void Add(WebUserControls.Control3 ctrl1, WebUserControls.Control3 ctrl2) {
ListBox listbox = ctrl1.FindControl("ListBox1") as ListBox;
if (ctrl1.Items.Count > 0) {
foreach (ListItem li in listbox.Items) {
if (li.Selected)
ctrl2.Add(li.Text, li.Value);
}
}
}
void Remove(WebUserControls.Control3 ctrl) {
ListBox listbox = ctrl.FindControl("ListBox1") as ListBox;
if (ctrl.Items.Count > 0) {
int count = ctrl.Items.Count;
for (int i = count - 1; i > -1; i--) {
if (listbox.Items[i].Selected)
ctrl.Remove(listbox.Items[i].Value);
}
}
}
見てください! "ctrl.Items"私はそれを使用しました。私はそれをどのように行うことができます
public PlaceholderItemCollection Items {
get {
return this.Placeholder.Items;
}
}
または
public PlaceholderItemCollection Controls {
get {
return this.Placeholder.Controls;
}
}
:しかし、私は次のようなプレースホルダとして他のコントロールを使用したいですか?