Format List look-up column as text-only in data-view web part
-
09-12-2019 - |
Vra
I have a list that contains a lookup column.
Next, I created an empty .aspx page and added a dataview web part. Next, I linked the dataview web part to the previously mentioned list, which gave me the data source.
Now, if I add the lookup column from the data source into the web part on my page and format it as a label, I get a label that is a hyperlink going to the backend (The list). If I format it as a textbox or just plain text, interestingly i get the following anchor tag on my page just like this:
<a onclick="OpenPopUpPage('http://cityapps.capetown.gov.za/sites/ikrc/_layouts/listform.aspx?PageType=4&ListId={8BEE076B-ABC8-4378-9CD4-93AD46064FC0}&ID=15&RootFolder=*', RefreshPage); return false;" href="http://cityapps.capetown.gov.za/sites/ikrc/_layouts/listform.aspx?PageType=4&ListId={8BEE076B-ABC8-4378-9CD4-93AD46064FC0}&ID=15&RootFolder=*">Final Test</a>
I also tried throwing the {@Research_x0020_Topic}
around into different html tags and asp controls, but I keep getting the above anchor on my page.
What I want is simple. I just want to display the value of the lookup column without it being a hyperlink. The closest I get is if i format it as a label:
<asp:Label runat="server" id="ff1{$Pos}" text="{@Research_x0020_Topic}" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Text','','ID',ddwrt:EscapeDelims(string(@ID)),'@Research_x0020_Topic')}" />
I cannot, however, seem to figure out how to disable the hyperlink embedded in this label.
Any help?
Oplossing
At the end the solution was quite simple. I just needed to add a column to the library that shows the value of the look-up as a data field by checking the following (Add a column to show each of these additional fields):
This creates a column in the library and the data source that acts like a normal single line of text field and not a look-up.