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

RadGrid NestedViewTemplate - bind from session variable throws exception

1 Answer 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 1
Ahmed asked on 23 Jan 2013, 01:34 PM
Hi,

I followed Grid/NestedViewTemplate Relations demo to bind one grid that has a nested view, everything is working properly.
But when using ObjectDataSource as a DateSource for NestedView and that object datasource uses a server side method to pull data from a Session variable, I'm getting
System.NullReferenceException: Object reference not set to an instance of an object

Here is ObjectDataSource declarative markup
<asp:ObjectDataSource runat="server" ID="MemberSubmissionData" TypeName="FacultyAnnualReview" SelectMethod="BindNestedView">
     <SelectParameters>
        <asp:Parameter Name="SubmissionId" Type="Int32" />
    </SelectParameters>
</asp:ObjectDataSource> 

and here is server side method
        public FacultyMemberSubmission BindNestedView(int submissionId)
        {
            return  (
                        from data
                        in GetFacultyMemberSubmissions()
                        where data.SubmissionId == submissionId
                        select data
                    ).SingleOrDefault();            
        } 

GetFacultyMemberSubmissions() method pulls data from a Session variable. When updating it to not use session, everything is working. So is that something that is related to ObjectDataSource or NestedView binding doesn't accept session variables. Any suggestions?

1 Answer, 1 is accepted

Sort by
0
Ahmed
Top achievements
Rank 1
answered on 23 Jan 2013, 01:43 PM
Fixed!

By defining select method as static and accessing session variable using HttpContext.Current.Session fixed NullReferenceException!
Tags
Grid
Asked by
Ahmed
Top achievements
Rank 1
Answers by
Ahmed
Top achievements
Rank 1
Share this question
or