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

RadGrid javascript error

1 Answer 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jesús
Top achievements
Rank 1
Jesús asked on 05 Mar 2009, 12:12 PM
Hi!

I have a RadGrid with some data. I group this data for some criteria (I call, p.e., tableori).

GridGroupByExpression expression = new GridGroupByExpression(); 
GridGroupByField gridGroupByField = new GridGroupByField(); 
 
//Add select fields (before the "Group By" clause) - Campo de ruptura 
gridGroupByField = new GridGroupByField(); 
gridGroupByField.FieldName = "tableori"
gridGroupByField.FormatString = "<strong>{0}</strong>"
expression.SelectFields.Add(gridGroupByField); 
 
//Add a field for group-by (after the "Group By" clause) - Agrupación 
gridGroupByField = new GridGroupByField(); 
gridGroupByField.FieldName "tableori"
expression.GroupByFields.Add(gridGroupByField); 
 
assigGrid.MasterTableView.GroupByExpressions.Add(expression); 
assigGrid.MasterTableView.ShowGroupFooter = true




The trouble is when I try to change the message at GroupHeader. When I try to sort the grid or paging it, I have the exception "Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive"; but if I comment the lines inside the if otpion of GridGroupHeaderItem works fine.

protected void assigGrid_ItemCreated(object sender, GridItemEventArgs e) 
    try 
    { 
        if (defObjeto == null
        { 
            objeto = Request.QueryString["obj"]; 
            idioma = UtilControlSession.GetIdioma(Session); 
            wc = new WebCache(Cache, (string)Session[Constantes.SESS_APLICACION_ACTIVA], bdConnStr); 
            defObjeto = wc.GetObjetoAsignacionH(objeto, idioma); 
        } 
 
        if (e.Item is GridGroupHeaderItem) 
        { 
            GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; 
 
            // Los datos que afectan a esta agrupación (criterio(s) de agrupación y subtotales si los hubiere) 
            DataRowView groupDataRow = (DataRowView)e.Item.DataItem; 
 
            int colSpan = item.Cells[1].ColumnSpan; 
            item.Cells.RemoveAt(1); 
 
            TableCell tc = new TableCell(); 
            tc.ColumnSpan = colSpan; 
            tc.HorizontalAlign = HorizontalAlign.Left; 
            tc.Text = "My title"
            item.Cells.Add(tc); 
        } 
    } 
    catch (Exception exc) 
    { 
    } 

Any ideas or suggestions to skip this problem?

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 10 Mar 2009, 07:37 AM
Hi,

First, you can make sure which line of code is raising the exception. If it is the line with a reference to the Session field, you must make sure that Session state is enabled for the page.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Jesús
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or