if (e.Item is GridDataItem) |
{ |
GridDataItem dataItem = (GridDataItem)e.Item; |
if (dataItem["Scenario"].Text == "Scenario1") |
{ |
foreach (Control ctrl in dataItem["Action"].Controls) |
{ |
ctrl.Visible = false; |
} |
dataItem["Action"].Controls[1].Visible = true; |
} |
else if (dataItem["Scenario"].Text == "Scenario2") |
{ |
//Do something else |
} |
Hello,
I have a GridTemplateColumn in my grid in which there are three LinkButton controls. Based on values in the current item, I need to be able to either show or hide these LinkButtons. The code above is from my grid's ItemDataBound event. As you can see, I'm accessing the controls in the column by their index. Isn't there a better way? Who knows what other controls might be in there that I'm unaware of...I might NOT want all of them to be invisible.
Eric Skaggs