I am building a ListView from an EntityDataSource. There is a Byte[] field called Sha1Hash that I need to convert to a String type for a Hyperlink. This is a code snippet from ItemTemplate:
<asp:HyperLink ID="hl_Document" runat="server"
NavigateUrl='<%# string.Format("~/GetDocument.ashx?docId={0}", Eval("SHA1HASH") ) %>'
Text='<%# Eval("DOCUMENTNAME") %>' />
This is producing a URL like “~/GetDocument.ashx?docId=System.Byte[]”, but it needs to be a hex string representing the value of the byte array. What would be the best approach to accomplish this? Ideally I would accomplish this entirely in the .aspx page rather than the code behind.
Update: I resolved this issue by using
NavigateUrl='<%# string.Format("~/GetDocument.ashx?docId={0}", BitConverter.ToString((byte[])Eval("SHA1HASH")).Replace("-", string.Empty) ) %>'
My problem was that I needed to cast Eval() to byte[]. It was being cast to string.
I resolved this issue by using
My problem was that I needed to cast Eval() to byte[].