locked
datalist & parameters RRS feed

  • Question

  • User1624010595 posted

    hi, im new to asp.net and im trying to make some changes the CSK. i tried to view the TITLES in the Announcement table (Page1.aspx) using datalist, converted it to a hyperlink. What i wanted is when the user click the link, it will goto page2.aspx and pass the id of table then display the DESCRIPTION to page2.aspx based on the ID passed..

    my code in page1.aspx are..

    <asp:DataList ID="DataList1" runat="server" DataSourceID="ObjectDataSource2">

    <ItemTemplate>

    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Page2.aspx"

    i want the above statement to look like...  ( ..... NavigateUrl="~Page2.aspx?ID=1" )

    so that when page2.aspx display, i already have a gridview that displays all items depending to the value at the URL..... something like that...

    Text='<%# Eval("title", "{0}") %>'></asp:HyperLink>

    </ItemTemplate>

    </asp:DataList><asp:ObjectDataSource ID="ObjectDataSource2" runat="server" InsertMethod="Insert"

     

    Thanks!

    my Page2.aspx looks something like this...

     

    <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">

    <ItemTemplate>

    <asp:Label ID="descriptionLabel" runat="server" Text='<%# Eval("description") %>'></asp:Label><br />

    <br />

    </ItemTemplate>

    </asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ClubConnectionString1 %>"

    SelectCommand="SELECT [description] FROM [Announcements] WHERE ([id] = @id)">

    <SelectParameters>

    <asp:QueryStringParameter Name="id" QueryStringField="AnnounceID" Type="Int32" />

    </SelectParameters>

    </asp:SqlDataSource>

    <br />

     

     

    Saturday, June 3, 2006 11:12 AM

All replies

  • User-1346905220 posted

    If you look at the News_List.aspx file you'll see an example of what you want to do (I believe it is line 100)

    <asp:HyperLink ID="newslink" runat="server" NavigateUrl='<%# "news_view.aspx?articleid=" &Cstr( Eval("ID"))%>' >

    Hope this helps.

    -Mike

    Saturday, June 3, 2006 10:45 PM
  • User1624010595 posted

    it worked. tnx mike!

    Saturday, June 3, 2006 11:28 PM