pwerstreak
asked on
Gridview: How to add a HyperLinkField to a TemplateField in CODE?
Could you give me an example on how I'd go about dynamically creating a TemplateField with a HyperLinkField added into it...the TemplateField would then get added to a column in the GridView...? It turns out the TemplateField's ItemTemplate can only be assigned an ITemplate, and the HyperLinkField does not implement that interface. I am looking for code, not tags in the aspx page.
The DataNavigateUrlFormatStrin g property in HyperLinkField cannot be assigned a value with ":", forexample if you wish to add "javascript:MyFunc();", and Microsoft gives the above solution as a workaround...
Appreciate it...Thanks!
The DataNavigateUrlFormatStrin
Appreciate it...Thanks!
http://forums.devx.com/archive/index.php/t-8289.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
see this article for dynamic template
http://www.codeproject.com/useritems/create_template_columns.asp
or this article
http://www.codeproject.com/useritems/dynamictemplatecolumn.asp
http://www.codeproject.com/useritems/create_template_columns.asp
or this article
http://www.codeproject.com/useritems/dynamictemplatecolumn.asp
I gave him 2 links with examples on dynamic templates.
Sandip explained the hyperlink column. My suggestion is if participant doesnt respond to split points.
Sandip explained the hyperlink column. My suggestion is if participant doesnt respond to split points.
ASKER
I was looking for a solution (C#) that allowed me to call a jscript function with "javascript:MyFunc();" when user clicks on the HyperLink... the "for example" part may have thrown you off.
My points go to Sandip even though he doesn't provide a solution for the "javacript:" issue...
KarinLoos, I was not looking for a general way to dynamically add columns to a datagrid (specifically TemplateField with a HyperLinkField).
My points go to Sandip even though he doesn't provide a solution for the "javacript:" issue...
KarinLoos, I was not looking for a general way to dynamically add columns to a datagrid (specifically TemplateField with a HyperLinkField).