Hi,
I am trying to use the photo_id of a picture whilst a user uses a datapager to select different images. I am also getting the photo_id of the pictures through a label within the listview. However now i need that value so i pull out comments from another table according to this photo_id…
I currently have th following code:-
<asp:ListView ID="lvPhotoViewer" runat="server" GroupItemCount="1"
onselectedindexchanged="lvPhotoViewer_SelectedIndexChanged">
<LayoutTemplate>
<table ID="groupPlaceholderContainer" runat="server" border="1">
<tr ID="groupPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<td id="Td4" align="center" style="background-color: #eeeeee;">
<asp:Image runat="server" ID="imPhoto" Height="450px" Width="450px" ImageUrl='<%# string.Format("~/photos/{0}", Eval("photo")) %>' />
<br />
<asp:Label ID="DefaultPhotIDLabel" runat="server" Text='<%# Eval("photo_name") %>' />
[B][U] <asp:Label ID="Label5" runat="server" Text='<%# Eval("photo_id") %>'/>[/U][/B]
</td>
</ItemTemplate>
<GroupTemplate>
<tr ID="itemPlaceholderContainer" runat="server">
<td ID="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
</asp:ListView>
<asp:DataPager ID="DataPager1" runat="server"
PagedControlID="lvPhotoViewer" PageSize="1"
onprerender="DataPager1_PreRender">
<Fields>
<asp:NextPreviousPagerField ButtonType="Link"
PreviousPageText="<< Previous" NextPageText="Next >>"/>
</Fields>
</asp:DataPager>
<asp:Label ID="Label6" runat="server" Text=""></asp:Label>
So as you can see the line that i have underlined shows where i read the photo_id from. Now i want to try and retrieve this value somehow so i thought of reading it through a label on page load.
I wrote the following code where i wanted the photo_id to appear in label 5, then i would get this value and use it later…
Heres the code:-
if (!Page.IsPostBack)
{
Label SourceTextBox = (Label)Page.FindControl("Label5");
if (SourceTextBox != null)
{
Label6.Text = SourceTextBox.ToString();
}
}
This is being done on page load. But the Label6 does not read any value so it means it is not being read from the list view.
Any ideas what im doing wrong?
Regards
Billy