General discussion

Locked

ASP.NET Datagrid Question

By galahad04 ·
I have a question about the HyperlinkColumn template item which can be used in ASP.NET's DataGrid object. Basically, I am trying to read e-mail addresses from a database table and then display them on a web page datagrid, with the e-mail addresses dynaminally linked to the e-mail address field using the mailto: tag. However, when I try to do this by concatenating the DataNavigateUrlFormatString property and the e-mail field object, I get a server error message that says something like "Databinding is not a property of DataGrid" (HyperlinkColumns doesn't like the <%# %> databinding syntax). Also I was hoping someone could let me know what I am doing wrong here and how I can achieve the desired result. Thanks

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

ASP.NET Datagrid Question

by MedievalDude In reply to ASP.NET Datagrid Question

Something I have tried with data grids (and I don't know if this will work in your situation, but what they hey)...
When I call the field from the database, I would embed the anchor tag with it so that the datagrid interprets it as HTML. Example:SELECT '<a href="' + MyURLField + '">' + MyURLField + '"</a>"' AS MyURLField FROM MyTable
Or in your case:
SELECT '<a href="mailto:' + MyEmailAddressField + '">' + MyEmailAddressField + '"</a>"' AS MyEmailAddressField FROM MyTable

Collapse -

ASP.NET Datagrid Question

by galahad04 In reply to ASP.NET Datagrid Question

Thanks for your suggestion. Unfortunately, this approach did not seem to work for me when I using it in my stored procedure.

Collapse -

ASP.NET Datagrid Question

by galahad04 In reply to ASP.NET Datagrid Question

Quick correction -- the part where I wrote "I get a server error message that says something like Databinding is not a property of DataGrid" should be listed as "I get a server error message that says something like Databinding is not a property of HyperlinkColumn".

Collapse -

ASP.NET Datagrid Question

by crispy1 In reply to ASP.NET Datagrid Question

I have never tried this, but I have a datagrid that navigates to a different page based on an id, when i change the link to the mailto: it opens my email composer and fills the to field with the id, so i am positive this should at least point you inthe right direction.
Good luck.

<asp:HyperLinkColumn Text="Click to Mail" DataNavigateUrlField="Email" DataNavigateUrlFormatString="mailto:{0}" HeaderText="Email"></asp:HyperLinkColumn>

Collapse -

ASP.NET Datagrid Question

by galahad04 In reply to ASP.NET Datagrid Question

This solved the problem perfectly! Plus very simple and elegant -- thanks a bunch! If you don't mind though, I do have a quick follow-up question: what exactly does the {0} syntax in the code represent? I tried researching it in the Visual Studio .NET help documentation, but could not find anything that explained how exactly this syntax works and what it represents. The senior programmers at work couldn't make any sense of it either. If you could please e-mail me at caramon@peoplepc.com, I would deeply appreciate it. Thanks again

Collapse -

ASP.NET Datagrid Question

by galahad04 In reply to ASP.NET Datagrid Question

This question was closed by the author

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums