我在ASP.NET中創建了動態列表框(4到10)。 和我的問題是,我如何找到使用C#動態創建列表框?在ASP.NET中查找列表框
謝謝
當然......我感謝您的幫助。下面的代碼我使用的用於創建動態LB
protected void btndyfilter_Click(object sender, EventArgs e)
{
int numberOfListBox = lbFilter.GetSelectedIndices().Length;
string lbname = lbFilter.SelectedValue;
for (int i = 0; i < numberOfListBox; i++)
{
ListBox listb = new ListBox();
ListItem lItem = new ListItem();
listb.SelectionMode = System.Web.UI.WebControls.ListSelectionMode.Multiple;
listb.Height = 150;
listb.Width = 200;
lItem.Value = i.ToString();
lItem.Text = lbname;
listb.Items.Add(lItem);
panFilter.Controls.Add(listb);
//once we created the LB dynamically i need to populate each LB with the corresponding values
connstr2 = System.Configuration.ConfigurationManager.ConnectionStrings["connstr"].ConnectionString;
conn2.ConnectionString = connstr2;
conn2.Open();
CubeCollection CubeList = conn2.Cubes;
string cb = ddlCubeList.SelectedItem.Text;
//need to remove the Hardcoded Code
foreach (Member dimem in CubeList[cb].Dimensions["Date"].Hierarchies["Calendar Date"].Levels["Date"].GetMembers())
{
ListItem Memlist = new ListItem();
Memlist.Text = dimem.UniqueName;
lbFilter.Items.Add(Memlist);
}
}
panFilter.Visible = true;
panCubeDef.Visible = true;
}
所以這將創建LB我相信:)...和註釋的代碼裏面我需要使用來填充每個LB項目..perhaps它咬硬編碼我需要刪除。所以我所有的動態的LB被填充,然後從所有磅選定的項目將進入我的MDX query..hope where子句我沒有混淆你
它可能有助於爲你增添一些更詳細的關於你正在試圖做 – Ortund
知道是什麼,並感謝尋找到它..基本上我所試圖做的是,我有我的網頁過濾器部分,這些過濾器值必須從我動態創建的列表框項目中選擇。所以爲此我需要找到動態列表框和它的項目,以後我可以構建我的where子句的查詢。希望這可以幫助你,以幫助我:) – user1849129
@ user1849129你能刪除評論嗎?並告訴我們,你會在哪裏使用該動態創建的控件。 – Aristos