Formatting one column of gridview based on value of another column
Posted on 2012-08-16
I am programming a web application in VB.NET.
I have a Gridview that I would like to display that lists document names, and their links. When the user clicks on the link - they will have access to the document.
The list of documents is in a database table called 'msgdocs'. The column with the document link is called 'linkURL' and the column with the type of link is called 'linktype'.
The problem is, I have 4 different types of documents (linktypes):
1. PDF documents - when the user clicks on this document, I would like it to open in a window... something like onclick="window.open('linkURL',null, 'width=700,height=500'); return false"
2. Other local documents - just have the browser download the document (ex: like a powerpoint file)
3. External documents - have the browser open a new tab (ie: code would be <a href='linkURL' Target = '_blank')
4. Another page on the portal - have the browser refresh the current page (ex: using a querystring variable, code would be 'mypage.aspx?pagnum=4')
So what I am trying so understand is how it could be possible to "wrap" the 'linkURL' in code to provide the above 4 behaviours, based on the value of the 'linktype' column.
Perhaps using onrowdatabound ?