I'm looking for a solution to bind a value to a column of a GridView control based on a condition.
Let's say I have a property:
public bool Perm
{
get;
set;
}
Based on that property, I want to set the bound field to a particular value.
Here I'm getting a list:
List<MyObject> obj = myservice.GetData().toList();
MyObject has the properties FullBankAcc and HiddenBankAcc.
Based on the value of the Perm property, I want to display either one value or another:
if (Perm)
{
// bind a column to a HiddenBankAcc
}
else
{
// bind a column to a FullBankAcc
}
This is the GridView column:
<asp:BoundField DataField="Display the value based on a property" HeaderText="ABA"/>
How can I do something like this?
One way would be add another readonly field to your MyObject class that wraps the logic you want and bind the column to that field.