This is a migrated thread and some comments may be shown as answers.

Radgrid Itemtemplate how to use If else condition to set Preprocessor directives

2 Answers 677 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
win
Top achievements
Rank 1
win asked on 18 Jul 2010, 07:21 AM
In the radgrid Itemtemplate how to use if else in the Preprocessor directives .Following code im using <%#eval("user-id)%> ,i need a check if user_id is null then #eval(secondcolumnid)  so i used
<ItemTemplate>
                                                    <a href="Userinfo.aspx?User_Id=<%if(#Eval("User_Id")!=null){#Eval("User_Id")} %>">edit</a> <%#Eval("Last_Name") %>,
                                                    <%#Eval("First_Name") %>
                                                </ItemTemplate>
If i use like this it throws me an error Preprocessor directives must appear as the first non-whitespace character on a line .
So what is the best way to solve this solution.
<telerik:RadGrid ID="Grd1" runat="server" AutoGenerateColumns="False" AllowPaging="True">
<MasterTableView DataKeyNames="userid" CellSpacing="1">
<Columns>
<telerik:GridClientSelectColumn ButtonType="PushButton" />
<telerik:GridTemplateColumn HeaderText="Manager">
<ItemTemplate>
<a href="userinfo.aspx?User_Id=<%#Eval("User_Id") %>">edit</a> <%#Eval("Last_Name") %>,<%#Eval("First_Name") %>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings Selecting-AllowRowSelect="true">
<Selecting AllowRowSelect="True" />
</ClientSettings>
</telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 22 Jul 2010, 08:47 AM
Hello win,

I am afraid the desired directives are not supported in ASP.NET. Therefore I suggest that you add the two labels for the both conditions and make only one of the visible at a time.

I hope this helps.

Kind regards,
Iana
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
0
win
Top achievements
Rank 1
answered on 24 Jul 2010, 11:31 PM
Thank you will try that.
Tags
General Discussions
Asked by
win
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
win
Top achievements
Rank 1
Share this question
or