Cross Page PostBack with ASP.NET 2 and a DataList

W

webserverpete

What code do I need to get the value of my Datalist using Cross Page
PostBack? Below is my DataList:

<asp:DataList ID="DataList1" runat="server"
DataSourceID="SqlDataSource1" RepeatColumns="4" DataKeyField="itemid">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "itemname")%> <br>
$<%#FormatNumber(DataBinder.Eval(Container.DataItem, "itemprice"),
2)%> <br>
<%#DataBinder.Eval(Container.DataItem, "itemdescription")%> <br>
<%#Format(DataBinder.Eval(Container.DataItem, "itemaddtime"), "ddd
MMMM d, yyyy h:mm tt")%> <br>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%#
"images/" & Eval("picfilename") %>' PostBackUrl='<%# "cart.aspx?id=" &
eval("itemid") %>' Width="200px" BorderStyle="None" /><br>
<asp:Button id="submit" runat="server" Text="Order" PostBackUrl='<%#
"cart.aspx?id=" & eval("itemid") %>' />
<asp:HiddenField runat="server" Value='<%# eval("itemid") %>'
ID="itemid" />
</ItemTemplate>
</asp:DataList>

I was trying this out but I did not get what I wanted:

Dim i As DataList
i = CType(Page.PreviousPage.FindControl("DataList1"), DataList)
Response.Write(i.FindControl("itemid").ToString)

Thanks for you help,
Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top