I would like to display data read from the database as links, each of which will call a js function when clicked.
The data read are inserted into a webgrid and displayed on the browser like this
<div>
@grid.GetHtml(
columns:grid.Columns(
grid.Column("Country"),
grid.Column("Capital")
)
)
</div>
That simply does the output but only the table heads are turned into links by default.
I have tried this
columns:grid.Columns(
grid.Column(columnName:"Country",header:"Country",format:@<a href="#" onclick="Find();return false;"></a>),
grid.Column("Capital")
)
But this deletes all the countries and replaces them with "" (empty string) and that is also not what I would like to do.
I would like to make the data output as links that can be clicked to execute "Find" js function. I don't know how to format the table data not the table heads
The text for a link appears between the opening and closing tags. You currently have nothing there. Alter it as follows to have the Country appear:
format:@<a href="#" onclick="Find();return false;">@item.Country</a>