Reputation: 24799
In my code i create a HyperLinkField object. Depending on a database field value, i want to set the NavigateUrl property. This is my problem, i don't know how.
With:
objHF.DataNavigateUrlFields = new[] { "id", "Stype" };
i get my database field. Now i want to check the Stype value. Depeding on this value i want to set the page where to navigate to. How can i do this??
At the end i set my datasource to the gridview and after that i call the bind() method.
I hope someone can help me out
Upvotes: 1
Views: 8605
Reputation: 11
try this way
<%# this.myUrlFunction(Eval("id"), Eval("stype")) %>
this is worked
Upvotes: 1
Reputation: 37215
Make the HyperLinkField a TemplateField, and set the NavigateUrl of the resulting HyperLink (in markup) to something like
<%# myUrlFunction(Eval("id"), Eval("stype")) %>
Next create a corresponding function in the .cs file:
private string myUrlFunction(object id, object stype)
{
return "mypagename.aspx?whatever=" + id.ToString() +
"&youwanttodo=" + stype.ToString();
}
Upvotes: 1