[英]how to telerik radgrid binding with a grid template column with the visibility of the delete icon on and off
我已經通過網格模板列綁定了telerik radgrid,並通過調用方法ISDeleteVisible后面的代碼確定了刪除圖標的可見性,該方法帶有對應列中的變量,但將其作為參數傳遞給我,但是當我加載頁面時,它說服務器標簽的格式不正確錯誤。
<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>
在后面的代碼中,我有方法后面的代碼
protected bool ISDeleteVisible(string AgencyType)
{
if(AgencyType=="HouseHoldAgency")
ISDELETE = true;
else
ISDELETE = false;
return ISDELETE;
}
您在Eval(“ AgencyType”)之后缺少右括號。
另外,只要將屬性值以內聯方式綁定,就應使用單引號而不是雙引號:
Visible='<%# ISDeleteVisible(Eval("AgencyType")) %>'
不相關 ,但是您的代碼隱藏方法有很多問題。 首先,您可以像這樣寫一行:
protected void IsDeletedVisible(string agencyType)
{
return AgencyType == "HouseHoldAgency";
}
如果您不想這樣寫,則需要聲明您的ISDELETED變量。 如果它是局部變量,則需要聲明它,如下所示:
bool isDeleted;
同樣,在編寫代碼時,大寫還是小寫都很重要。 在決定對方法,變量,屬性等的名稱使用大寫字母還是小寫字母時,應格外小心。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.