This is a migrated thread and some comments may be shown as answers.
Inline Condition in Template Field
2 Answers 39 Views
This is a migrated thread and some comments may be shown as answers.
AMS
Top achievements
Rank 1
AMS asked on 18 Jun 2010, 03:26 PM
I am using an inline if condition in a grid which is based on a bound field and another field. While implementing the if condition in Eval statement, i am getting an unknown error.

 <telerik:GridTemplateColumn> 
                    <ItemTemplate> 
                        <table class="search_results_new" border="0" cellpadding="0" cellspacing="0"
                            <tr class="suggestionResults" title="select to edit suggestion"
                                <td> 
                                       <% if (ViewData["UserLevelBySCDS"].ToString() == "1" || (ViewData["UserLevelBySCDS"].ToString() == "2" && Eval("ResourceCategoryID").ToString() == "1") || (ViewData["UserLevelBySCDS"].ToString() == "4" && Eval("ResourceCategoryID").ToString() == "2"))   //  
                                        { %> 
                                        <!-- Delete Suggestion Original-->         
                                                Res Cat Id: <%# Eval("ResourceCategoryID").ToString() == "1" ? "Xplore" : "District" %>   <!-- Temporary line -->       
                                                <input id="hfResourceCategoryID" name="hfResourceCategoryID" type="hidden" value='<%# Eval("ResourceCategoryID")%>' /> 
                                                <div id="deleteSuggestion" class="deleteSuggestion">  
                                                    <input id="hfSuggestionID" type="hidden" value='<%# Eval("SuggestionID") %>' /> 
                                                </div> 
                                                <%# Html.ActionLink("-", "Edit", new { pID = Eval("SuggestionID") }, new { id = "A1", @class = "editMyResource"style="display: inline;" }) %> 
                                                 
                                                <!-- End of Delete Suggestion -->         
                                             
                                        <% } %>  
                                         
                                     <span> 
                                        <href='<%# Eval("Link")%>' target="_blank"
                                            <%# Eval("ResourceType.Description")%> 
                                        </a> 
                                        <br /> 
                                        <b> 
                                            <div onclick="window.open('<%# Eval("Link")%>')"
                                                <u> 
                                                    <%# Eval("Link")%></u
                                             </div> 
                                        </b> 
                                     </span> 
                                     <i> 
                                            <div class="rating" id="mainStarDiv"
                                                <input id="hfSuggestionID" name="hfSuggestionID" type="hidden" value='<%# Eval("SuggestionID")%>' /> 
                                                <input id="hfDefaultRating" type="hidden" value='<%# Eval("Rank")%>' /> 
                                                <div class="star" id="star1" starrank="1"
                                                    <href="javascript:void(0);" style="width: 100%;">1</a></div
                                                <div class="star" id="star2" starrank="2"
                                                    <href="javascript:void(0);" style="width: 100%;">2</a></div
                                                <div class="star" id="star3" starrank="3"
                                                    <href="javascript:void(0);" style="width: 100%;">3</a></div
                                                <div class="star" id="star4" starrank="4"
                                                    <href="javascript:void(0);" style="width: 100%;">4</a></div
                                                <div class="star" id="star5" starrank="5"
                                                    <href="javascript:void(0);" style="width: 100%;">5</a></div
                                            </div> 
                                        </i> 
                                </td> 
                            </tr> 
                        </table> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 




Please note that i am implementing this grid in MVC and please do not refer me to use Telerik MVC Grid.

2 Answers, 1 is accepted

Sort by
0
AMS
Top achievements
Rank 1
answered on 18 Jun 2010, 03:31 PM
I have also tried this approach to implement it, but this time i am getting the error mentioned below:

Message:d:\PROJECTS_WORKING\Xplore.Ver2_Production\XploreVer2.Web\Views\Suggestion\Index.aspx(24):error CS1513: } expected

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"
    <%= Html.Stylesheet("districtResource-rating.css")%> 
    <%= Html.ScriptInclude("suggestion-list.js")%> 
    <%= Html.ScriptInclude("myResources-rating.js")%> 
    <%--<%= Html.ScriptInclude("resource-modification.js")%>--%> 
     
     
    <%  
         
     rgDistrictRes.DataSource = Model
     rgDistrictRes.DataBind(); 
      
    %> 
    <
     
     protected string AllowRender(string userLevelbySCDS, int resourceCategoryID) 
        {    
         StringBuilder sb;    
         if (userLevelbySCDS == "1" || (userLevelbySCDS== "2" && resourceCategoryID == 1) || (userLevelbySCDS== "4" && resourceCategoryID == 2))    
         { 
             sb.Append("<div id='deleteSuggestion' class='deleteSuggestion'>");  
             sb.Append("<input id='hfSuggestionID' type='hidden' value=" + Eval("SuggestionID") + "/>");  
             sb.Append("</div>");  
             sb.Append(Html.ActionLink("-", "Edit", new { pID = Eval("SuggestionID") }, new { id = "A1", @class = "editMyResource"style="display: inline;" });  
         } 
         return sb;    
     
        } 
     %> 
     
<!-- 
 In this case i am getting this error: 
Message: d:\PROJECTS_WORKING\Xplore.Ver2_Production\XploreVer2.Web\Views\Suggestion\Index.aspx(24): error CS1513: } expected  
 
--> 
 
-------- ------------------------------------------------------------------ 
 
<telerik:GridTemplateColumn> 
                    <ItemTemplate> 
                        <table class="search_results_new" border="0" cellpadding="0" cellspacing="0"
                            <tr class="suggestionResults" title="select to edit suggestion"
                                <td> 
                                       <%# AllowRender(ViewData["UserLevelBySCDS"].ToString(),Convert.ToInt32(Eval("ResourceCategoryID")) %> 
                                     <span> 
                                        <href='<%# Eval("Link")%>' target="_blank"
                                            <%# Eval("ResourceType.Description")%> 
                                        </a> 
                                        <br /> 
                                        <b> 
                                            <div onclick="window.open('<%# Eval("Link")%>')"
                                                <u> 
                                                    <%# Eval("Link")%></u
                                             </div> 
                                        </b> 
                                     </span> 
                                     <i> 
                                            <div class="rating" id="mainStarDiv"
                                                <input id="hfSuggestionID" name="hfSuggestionID" type="hidden" value='<%# Eval("SuggestionID")%>' /> 
                                                <input id="hfDefaultRating" type="hidden" value='<%# Eval("Rank")%>' /> 
                                                <div class="star" id="star1" starrank="1"
                                                    <href="javascript:void(0);" style="width: 100%;">1</a></div
                                                <div class="star" id="star2" starrank="2"
                                                    <href="javascript:void(0);" style="width: 100%;">2</a></div
                                                <div class="star" id="star3" starrank="3"
                                                    <href="javascript:void(0);" style="width: 100%;">3</a></div
                                                <div class="star" id="star4" starrank="4"
                                                    <href="javascript:void(0);" style="width: 100%;">4</a></div
                                                <div class="star" id="star5" starrank="5"
                                                    <href="javascript:void(0);" style="width: 100%;">5</a></div
                                            </div> 
                                        </i> 
                                </td> 
                            </tr> 
                        </table> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 

0
Pavlina
Telerik team
answered on 24 Jun 2010, 11:13 AM
Hello Abbid,

Please note that you can not put the server side code in asp.net page. Regarding your second approach we are not able to replicate the issue locally without a working project. Therefore I suggest that you open a formal support ticket and send us a simple runnable application. Thus we will be able to further investigate on your project and isolate the root cause of the presented issue.

Looking forward for your reply.

All the best,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
AMS
Top achievements
Rank 1
Answers by
AMS
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or