How to tell a GridViewRow to perform as a SEO-friendly link?
I have a GridView that has multiple columns.开发者_C百科 Let's say I have a business modell that looks like this:
public class MyObject
{
public String Title {get;set;}
public DateTime Date {get;set;}
public String NavigateUrl {get;set;}
}
My grid has two visible columns (Title and Date).
What I want to do, is to make each row clickable and to act like a link, that is going to the specified NavigateUrl. No problem so far.I could use the OnRowDataBound-Event to assign a Javascript that tells the Grid that I performed a Select and in the OnRowEvent, I could perform a Response.Redirect. But that is not what I want to do, because it is not SEO friendly.
How can I make the whole "grid row as link" idea SEO friendly?
Edit: Adding an extra, visible column is no option
Provide a link as a column in the grid, and make the tr's onclick event fire off the link.
What you want is to make the GridView's cell contents LinkButtons, with the NavigateUrl specified. They will then show up as ordinary links on the page. You can define this behavior in the ASPX/ASCX markup and then DataBind, or dynamically build your GridView by adding rows manually in a loop through your data objects, setting the properties manually. Either one will work; I daresay databinding may be a bit faster but it can also be fiddly.
精彩评论