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

Using Literals in RadGrid?

1 Answer 343 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Miklos
Top achievements
Rank 1
Miklos asked on 13 Jul 2008, 12:40 PM
Hi,

I have a RadGrid setup which displays info from a table. In one specific column I need to get additional information using a static function and display it next to the cell value. I tried using the <%# %> but it just complained that it doesn't allow it. Is there a way to call a static function  in the namespace, add the databound parameter as an input parameter and get the result?  Here is the code I tried:

<telerik:GridBoundColumn DataField="uwr_id" DataType="System.Int64"  
            HeaderText="Request ID"  
            ReadOnly="True"  
            SortExpression="uwr_id"  
            UniqueName="uwr_id" 
            DataFormatString="<%# Base.DBManager.getRelatedTasks(DataBinder.Eval(Container.DataItem,"uwr_id")) %>" > 
        </telerik:GridBoundColumn> 

The DBManager getRelated tasks is as follows:
public static string getRelatedTasks(object obj) 
        { 
            long uwr_id = (long)obj; 
            string res = "SIMPLE RES "//no processing, just for testing 
       
            return res; 
        } 

This is the error I get:
Server Error in '/' Application. 
Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 
 
Parser Error Message: Literal content ('<telerik:GridBoundColumn DataField="uwr_id" DataType="System.Int64" 
           HeaderText="Request ID" ReadOnly="True" SortExpression="uwr_id" UniqueName="uwr_id" 
           DataFormatString="') is not allowed within a 'Telerik.Web.UI.GridColumnCollection'. 
 
Source Error: 
 
Line 23: </ExpandCollapseColumn> 
Line 24:     <Columns> 
Line 25:         <telerik:GridBoundColumn DataField="uwr_id" DataType="System.Int64"  
Line 26:             HeaderText="Request ID" ReadOnly="True" SortExpression="uwr_id" UniqueName="uwr_id" 
Line 27:             DataFormatString="<%# Base.DBManager.getRelatedTasks(DataBinder.Eval(Container.DataItem,"uwr_id")) %>" > 
 
 
Source File: /admin/AdmWebsiteRequests.aspx    Line: 25 
 
Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434 



Any suggestions?

Miklos

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 14 Jul 2008, 05:16 AM
Hi Miklos,

Binding expression can be used in ASP.NET Controls - the grid columns are IStateManager.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Miklos
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or