Hi,
I have been Googling for a solution but I haven't found one. What I need to do is relatively simple I think. I am using a GridHyperLinkColumn. Sometimes the user will not have permission to view a particular link though.
So, in the code behind what I have at the moment is something like the code below. What I need to fill in is the what goes here ?????? bit. Is it possible to populate NavigateUrl with something that will make OnItemCommand fire in the normal way?
protected
void
OnItemDataBound(
object
sender, GridItemEventArgs e)
{
var gridDataItem = e.Item
as
GridDataItem;
if
(gridDataItem !=
null
)
{
var entity = gridDataItem.DataItem
as
MyEntity;
if
(entity !=
null
)
{
if
(CanViewThisEntity)
{
var url = GetLinkForEntitySomehow();
var link = (HyperLink)gridDataItem[
"Name"
].Controls[0];
if
(!
string
.IsNullOrEmpty(url))
{
link.NavigateUrl = url;
}
}
else
{
what goes here ??????
}
My problem at the moment is that OnItemCommand will fire only if the cell is clicked somewhere outside the text of the anchor tag (because the anchor is being rendered without a link).Or is there a better way maybe. I hope I am making sense!
Thanks.