How to bind the column values dynamically based on some condition

This code snippet will demonstates how to bind the column value dnamically,based on some condition my can be binded by different entities

ASPX page

<telerik:RadGrid ID="radgrdBusinessRuleRange" runat="server" AutoGenerateColumns="false" GridLines="None" BorderWidth="0" AllowSorting="true" AllowMultiRowSelection="false" PageSize="20" AllowPaging="true" PagerStyle-Mode="NextPrev" PagerStyle-AlwaysVisible="true" OnItemCommand="radgrdBusinessRuleRange_ItemCommand" onitemcreated="radgrdBusinessRuleRange_ItemCreated" OnItemDataBound="radgrdBusinessRuleRange_ItemDatabound" OnPreRender="radgrdBusinessRuleRange_PreRender">
<MasterTableView DataKeyNames="ID, TypeID">                    
<Columns>
<telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="#">                            
<ItemTemplate>
<asp:Label ID="numberLabel" runat="server" />                                
<%# Container.DataSetIndex+1 %>                            
</ItemTemplate>                        
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="RuleName" UniqueName="RuleName">                            
<ItemTemplate>                         
  <asp:LinkButton ID="lnkEdit" runat="server" CommandName="SomeCommand" Text='<%# Eval("Name") %>'>
</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>                         
<telerik:GridTemplateColumn UniqueName="RuleType" HeaderText="Type">
<ItemTemplate>                                
<asp:Label ID="lblRuleType" runat="server" />
                            </ItemTemplate>                        
</telerik:GridTemplateColumn>                        
<telerik:GridTemplateColumn UniqueName="Value1" HeaderText="Value">
<ItemTemplate> <asp:Label ID="lblValue1" runat="server" Text = '<%# getValue(Container.DataItem, Eval("TypeID")) %>'/> </ItemTemplate>   ///This column text can be differ based on some condition,so i have handle this in CS page                     
</telerik:GridTemplateColumn>                        
<telerik:GridTemplateColumn UniqueName="Value2" HeaderText="Max" >
<ItemTemplate>
<asp:Label ID="lblValue2" runat="server" Text='<%# Eval("MaxRange") %>'/>                            
</ItemTemplate>                        
</telerik:GridTemplateColumn>
</Columns>
<NoRecordsTemplate> There are No Record(s) to display. </NoRecordsTemplate>
</MasterTableView>
</telerik:RadGrid>
 

CS Page

Here based on Type, Name values can be bind

public string getValue(object c, object value)

{

List<BusinessRuleType> types = (List<BusinessRuleType>)ViewState["types"];

string typeName = types.Find(item => item.ID == (int)value).Type;

if (typeName == "Input")
{

return DataBinder.Eval(c, "InputValue").ToString();
}

else if (typeName == "Range")

{

return DataBinder.Eval(c, "MinRange").ToString();
}

else if (typeName == "Bool")

{

return DataBinder.Eval(c, "BoolValue").ToString();

}

else if (typeName == "Formula")
{

return DataBinder.Eval(c, "Value").ToString();
}

return "";

}