I've searched for this, but maybe I'm using the wrong keywords.
I have a DataList containing an ImageButton whose ImageUrl property I want to set by combining it with a string returned from a codebehind file property and a database value.
I have a protected property in my codebehind called strPath
.
I want to combine it with a database value in my aspx file. Like so:
... ImgUrl = '<%#strPath+ Bind("senderPic")%>' ...
But this doesn't work. How can I do this?
EDIT:
HEre's the entire code for the DataList as asked. (The problem is in the ibtnUser
element.
<asp:DataList ID="dtlstScraps" runat="server" CellSpacing="4"
onitemcommand="dtlstScraps_ItemCommand"
onitemdatabound="dtlstScraps_ItemDataBound">
<ItemTemplate>
<table class="style26">
<tr>
<td>
<asp:Panel ID="pnlHeader" runat="server" BackImageUrl="~/Images/scraphead.gif"
Height="50px" Width="640px">
<table class="style27">
<tr>
<td class="style28">
</td>
<td class="style29">
**<asp:ImageButton ID="ibtnUser" ImageUrl='<%# strPath + DataBinder.Eval(Container.DataItem, "senderPic") %>' CommandName ="ImageClick" runat="server" Height="35px" Width="35px" />**
</td>
<td class="style34">
<asp:LinkButton ID="lbtnUser" Text='<%#Bind("senderName")%>' CommandName="LinkClick" runat="server">User Page</asp:LinkButton>
</td>
<td class="style35">
<asp:Label ID="lblTimeStamp" Text='<%#Bind("timestamp")%>' runat="server" ></asp:Label>
</td>
<td class="style33">
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" Height="60px">
<asp:Label ID="lblMsg" runat="server" BackColor="#C9C9C9" BorderColor="#020246"
BorderStyle="Solid" Height="50px" Text='<%# Bind("message") %>' Width="631px"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>