View Complete Post
I have some data stored in a parent child relationship in a single table. I have Sections and Sub-Sections and just the two levels will exist.
I need to group the output in a nested unordered list fashion, grouping the sub-sections with their corresponding section.
- Sub-Section 1 of 1
- Sub-Section 2 of 1
- Sub-Section 1 of 2
- Sub-Section 2 of 2
Here is my DB table definition
CREATE TABLE [dbo].[Sections]( [SectionID] [int] IDENTITY(1,1) NOT NULL, [Title] [varchar](200) NOT NULL, [Number] [int] NOT NULL, [ParentID] [int] NULL, [Timestamp] [timestamp] NOT NULL, [Active] [bit] NOT NULL, CONSTRAINT [PK_Sections] PRIMARY KEY CLUSTERED ( [SectionID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]
I was planning to approach this by left joining the tabel on itself to get the sub-sections then use group by to sort things out. I am pretty lost on how to get the Grouping stuff to work in LINQ..
Here is my code...
var sections = from section in dataContext.Sections join subSec
I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!
I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.
On the masterpage, I have the following code:
Public Overridable ReadOnly Property SearchRes()
Private Sub DoSearch()
'some code to get a linq result
If res.Any Then
_res = res
LabelNoRes.Visible = True
On the SearchResults.aspx page I have this code.
Dim m As pxSite = CType(Page.Master, MasterPage)
If m.SearchRes IsNot Nothing Then
Label1.Text = "Results found = " & m.SearchRes.Count
m.searchRes is always nothing.
What am I doing wrong here?
I'm not sure how to structure the code for this but what I want to do is be able to add data to a database, and once this has completed successfully, then email the user to say the details have been added successfully to the database.
I need to:
1. Check that the relevant data has been added into the database then
2. Email the details of the relevant data when completed.
Thanks in advance for your help,