這是我的直放站從我的代碼放置一個變量背後Repeater控件中的NavigateUrl
<asp:Repeater ID="blogRepeater" runat="server">
<ItemTemplate>
<br />
<asp:Image ID="Image1" runat="server" Height="56px" ImageUrl='<%= string.Format(My_Variable) %>' Width="64px" />
<asp:HyperLink ID="HyperLink2" runat=server NavigateUrl='<%#Eval("Company_ID", "CompanyProfile.aspx?ID={0}")%>'><%#Eval("Name")%></asp:HyperLink>
<br />
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</asp:Repeater>
這是我在頁面加載
' Define data objects
Dim conn As Data.SqlClient.SqlConnection
Dim Comm As Data.SqlClient.SqlCommand
Dim reader As Data.SqlClient.SqlDataReader
conn = New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
Comm = New Data.SqlClient.SqlCommand(_
("SELECT Company_ID, Name FROM CompanyTable ORDER BY Name"), conn)
Dim My_Variable As String
My_Variable = "~/createthumb.ashx?gu=/images/Logo.bmp" + "&xmax=75&ymax=75"
' Open the connection
conn.Open()
' Execute the category command
reader = Comm.ExecuteReader()
' Bind the reader to the repeater.......................
blogRepeater.DataSource = reader
blogRepeater.DataBind()
' Close the reader
reader.Close()
' Close the connection
conn.Close()
背後代碼現在,我有一個名爲My_Variable
變量。我如何在上面的Repeater中放置變量My_Variable
?
請檢閱我更新的代碼:我實際上需要更改圖片網址......... – Etienne 2009-04-26 12:21:20