i have telerik radgrid binding with a grid template column with the visibility of the delete icon decided by calling the code behind method ISDeleteVisible with variable from the correponding column is being passed as parameter but when i load the page it says server tag is not well formed error.
<telerik:GridTemplateColumn AllowFiltering="false" UniqueName="Options">
<ItemTemplate>
<asp:ImageButton ID="imgDelete" runat="server" CommandName="cmdDelete" ToolTip="Delete"
Visible="<%# ISDeleteVisible(Eval("AgencyType") %>" CommandArgument="Container.DataItemIndex"
CausesValidation="False" ImageUrl="<%$ Resources:WebResource, deleteIcon %>"
OnClientClick="javascript:return confirm('Are you sure you want to delete?');" />
</ItemTemplate>
<ItemStyle Width="100px" />
</telerik:GridTemplateColumn>
in the code behind i have the code behind method as
protected bool ISDeleteVisible(string AgencyType)
{
if(AgencyType=="HouseHoldAgency")
ISDELETE = true;
else
ISDELETE = false;
return ISDELETE;
}
You are missing a closing bracket after Eval("AgencyType").
Also, use single quotes instead of double quotes whenever attribute values are bound inline like this:
Visible='<%# ISDeleteVisible(Eval("AgencyType")) %>'
Unrelated, but your code-behind method has numerous problems. Firstly, you could write it one line like this:
protected void IsDeletedVisible(string agencyType)
{
return AgencyType == "HouseHoldAgency";
}
If you don't want to write it like that, then your ISDELETED variable needs to be declared. If it is a local variable, you will need to declare it, like this:
bool isDeleted;
Also, upper case vs lower case is important when writing code. You should be careful when deciding whether to use an upper case letter or a lower case letter for the names of your methods, variables, properties etc.