Results 1 to 8 of 8

Thread: [RESOLVED] Datalist SelectField or HyperlinkField to get item details url?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2010
    Posts
    53

    Resolved [RESOLVED] Datalist SelectField or HyperlinkField to get item details url?

    Hello,
    I'm trying to place select hyperlink, or button to get item details on another page. In DataGrid control it is very easy to do it, I have just add HyperLinkField, and add Url parameter details.aspx?id={0}.

    I have tried with below code, but of course it is not working, as getting error:
    "Input string was not in a correct format"

    Code:
    <asp:HyperLink  id="HyperLink1" runat="server" navigateurl="details.aspx?id={0}"> Details</asp:HyperLink>
    Thank you in advance for help to anyone.

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Datalist SelectField or HyperlinkField to get item details url?

    Hello dejanc,

    Where exactly are you seeing that message? When you click the HyperLink?

    Can you show some more of the code that you are using? i.e. the code to bind your data to the GridView?

    Gary

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2010
    Posts
    53

    Re: Datalist SelectField or HyperlinkField to get item details url?

    Hi,
    already have a code.

    Code:
    <asp:HyperLink  id="HyperLink1" runat="server"  NavigateUrl='<&#37;#"details.aspx?Id=" & DataBinder.Eval(Container.DataItem, "You Column Value")%>'></asp:HyperLink>

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Datalist SelectField or HyperlinkField to get item details url?

    Hello,

    That is not the code that I asked for

    Where is the code that you use to bind the information to the GridView. i.e. are you using a SqlDataSource, or are you manually binding the GridView?

    Gary

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2010
    Posts
    53

    Re: Datalist SelectField or HyperlinkField to get item details url?

    Sure, no problem :-)

    Code:
    <asp:DataList ID="DataList1" runat="server" DataKeyField="ID" 
            DataSourceID="AdvancedSqlDataSource1" RepeatColumns="3" 
            Width="934px" CellPadding="4" ForeColor="#333333" BorderColor="#3399FF" 
            BorderWidth="1px" GridLines="Both" style="margin-bottom: 39px" 
            RepeatDirection="Horizontal">

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Datalist SelectField or HyperlinkField to get item details url?

    Hello,

    I have just noticed this:

    Code:
    NavigateUrl='<&#37;#"details.aspx?Id=" & DataBinder.Eval(Container.DataItem, "You Column Value")%>'>
    Is "You Column Value" really what your column is called?

    I would HIGHLY recommend that you move away from using Server Side code in your ASPX markup, put it in the code behind where it belongs. You can easily do what you are trying to achieve using the RowDataBound event of the GridView.

    Gary

  7. #7

    Thread Starter
    Member
    Join Date
    Apr 2010
    Posts
    53

    Re: Datalist SelectField or HyperlinkField to get item details url?

    No, this is just a template code. I have column with uniq names.

    Thank you for tips.

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Datalist SelectField or HyperlinkField to get item details url?

    Ok, that makes sense.

    I would definitely look into the RowDataBound event.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width