[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.
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
Re: Datalist SelectField or HyperlinkField to get item details url?
Hi,
already have a code.
Code:
<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl='<%#"details.aspx?Id=" & DataBinder.Eval(Container.DataItem, "You Column Value")%>'></asp:HyperLink>
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
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">
Re: Datalist SelectField or HyperlinkField to get item details url?
Hello,
I have just noticed this:
Code:
NavigateUrl='<%#"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
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.
Re: Datalist SelectField or HyperlinkField to get item details url?
Ok, that makes sense.
I would definitely look into the RowDataBound event.
Gary