我正在編寫一個for循環,顯示帶有一些chartfx顯示的鏈接列表。 chartfx需要一個sqlDataSource。每次for循環執行一次迭代時,我試圖給出唯一的ID,但是我無法將它傳遞給一個值或函數。下面的例子在我的代碼中。 getSQLID()只是一個函數,它返回一個字符串,我想成爲我的ID。這一切都在aspx頁面上完成,並且該函數位於.cs中。任何幫助將非常感謝你。如何使用變量或函數在HTML中聲明我的SqlDataSource ID
//name of the contentplace holder on the aspx page
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server" >
//code behind
Control ctrl = LoadControl("WebUserControl.ascx");
Control placeHolderControl = this.FindControl("Content2");
Control placeHolderControl2 = this.FindControl("ContentPlaceHolder1");
ctrl.ID = "something";
if (placeHolderControl != null)
placeHolderControl.Controls.Add(ctrl);
if (placeHolderControl2 != null)
placeHolderControl2.Controls.Add(ctrl);
嗯。似乎這不是解決問題的最佳方法。您是否需要爲每個chartfx控件分別創建一個SqlDataSource? – jadarnel27 2013-03-26 15:18:56
是的,我會的,每個人都顯示自己的結果基於sqlDataSource – dreebee 2013-03-26 15:35:35
'for'循環在哪裏? – bmm6o 2013-03-26 23:52:01