Datareader - Loop Through Result Set And Generate A Menu Structure?

Feb 1, 2010

I would like to loop through my result set and generate a menu structure like this:

page
page
subpage
subpage
page
page

[code]....

View 5 Replies


Similar Messages:

DataSource Controls :: Datareader - Loop Through Results In VB?

Feb 1, 2010

I would like to loop through my result set and generate a menu structure like this:

pagetitle
pagetitle
subtitle
subtitle
pagetitle
pagetitle

So far I have the following code but it doesn't generate the menu?

While reader.Read()
' set title
sitetitle = reader.Item("siteName")
mydata &= reader.Item("pagetitle")
' check subtitle exists, if so, build menu, loop though subtitles somehow?
if not IsDBNull(reader.Item("subtitle"))
mydata = "<ul>"
mydata &= "<li>" & reader.Item("subtitle") & "</li>"
mydata &= "</ul>"
end if
End while

Qeury and result set below:

sql:

SELECT subpages.subpageid, pages.pageid, sites.sitename, sites.siteid, pages.siteid,pages.pagetitle, subPages.subtitle FROM pages LEFT JOIN sites ON pages.siteid = sites.siteid LEFT JOIN subpages ON subpages.subpageid= pages.pageid WHERE sites.siteID = 1 ORDER BY sites.siteid, pages.pageid, subpages.subpageid ASC

results:

subpageid | pageid | siteid | siteid | pagetitle | subtitle
NULL 1 SCHS 1 1 Sandwell Community Healthcare Services NULL
NULL 2 SCHS 1 1 About Us NULL
NULL 3 SCHS 1 1 Your Services NULL
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 1111
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 2222
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 333
4 4 SCHS 1 1 Equality and Diversity Team at SCHS 44444
NULL 5 SCHS 1 1 Single Equality Scheme NULL
NULL 6 SCHS 1 1 Diversity Strands NULL
NULL 7 SCHS 1 1 Equality Impact Assessments NULL
NULL 8 SCHS 1 1 Quality and Safety Committee NULL
NULL 9 SCHS 1 1 Contact Us NULL

View 5 Replies

Loop Database Result In Groups?

Apr 2, 2010

I have a query that returns a pretty big result. I want to break the big set into several smaller sets to pass into a function. If i had a 100 records returned, how would i get 10 datasets?

View 1 Replies

Way To Get All User Result From SQL Query Using For Loop?

Nov 5, 2011

I would like to get the list of users (from db) who meets my SQL select statement, and send email for each of them.my current looks like this

Code:

Dim constguser As New SqlConnection
constguser.ConnectionString = ConfigurationManager.ConnectionStrings("xxxxxxxx").ToString
Dim email1D, email2D, userNickName, userName, rc As String
constguser.Open()

[code]....

If i run this code its only going to get the name and email of the first result found. I was wondering if there is a faster way to get all user result from the sql query, myb using a for loop?

View 7 Replies

Web Forms :: Put Multilevel Navigation Structure (from A Database) Into The Menu - Control

Jul 23, 2010

In classic ASP I would write some logic to get a nice menu on the site, but now with the Menu-control, it's as easy as it gets.. Maybe to easy. I can't quite figure out how I would do this.. I have a multilevel navigation structure (from a database) that I want to put into the Menu-control, but I don't know which approach is the best/easiest way for me..

I'm all into performance, usability and all that.. The only thing I have really decided is that I want to use the Menu-control, I haven't decided what datasource I should use or how to style the individual links my way The data is coming from a database and is not supposed to be changed very often (maybe once or twice every month).. Thought of making an XML-sitemap, but also of making some sort of SQL-hookup.. I'm leaning towards the XML-sitemap because it wouldn't take long to generate the XML every time the navigation changes and that won't happen very often. The next issue is styling, how to do that? I have the neccesary css ready for the individual links, but I'm still unsure of how to get it to the Menu-control.. The css I have looks like below and in its current form is intended just for the anchors

[Code]....

View 4 Replies

MVC :: Generate View With Loop And Metadata Class?

Feb 12, 2011

I'n trying to setup a view template dynamically using a foreach loop. The view template is as follows:

[Code]....

My metadata class is as follows:

[Code]....

The partial seems to render the labels correctly, displying the appropriate name for the fiields that I have annotated. However the value of the fields is always set to the class property name itself rather than the value of the given record itself.Now I'm pretty sure my problem is something stupid, but I can't see what I am missing. I followed Brad Wilson's guide here adjusting it for Razor's syntax:http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-4-custom-object-templates.html

View 4 Replies

ADO.NET :: Generate Strongly Typed Datatables From Multiple Result Set Proc?

Nov 23, 2010

For a reporting stored procedure that returns multiple result sets that don't map to

any database tables, I'm able to use SqlConnection(), fill a DataSet, and name the

different tables uniquely (as opposed to the default Table, Table1, Table2).

However, I want to make the returned DataTables to be strongly typed.

There's plenty of articles out there about strongly typed DataSets, etc.,

View 2 Replies

JQuery :: Use DB Query Result To Generate Required Lines Of Code?

Aug 24, 2010

I 'm gonna query database for photo records. each record include "photo path" where imagesURL stored in string format

I Choses my favorite Juqery plugin to show images. Plugin needs some lines of code like below.

How could I generate these lines

[Code]....

View 1 Replies

DataSource Controls :: SQl Query - Generate Another  Computed Column That Will Contail The Result Of GrandTotal/Total?

Jun 30, 2010

How do i generate another computed column that will contail the result of GrandTotal/Total,


where GrandTotal is another value comes from computed column and the Total would be the sum of the Total within SchedularID.

And thats what i have done so far: [Code]....

View 3 Replies

Datareader Vs Dataset - Get The Number Of Rows From The Datareader?

Nov 15, 2010

I'm having a method that exports content from the database to excel files. The method taks as paramaters a DataReader param and a int param - the number of rows. For the number of rows i'm using a dataset, wich i fill using the same query as for the datareader. So I'm executing it twice... Is there a way I can avoid that? get the number of rows from the datareader?

View 1 Replies

MVC :: Generate Hierarchical Menu From Database?

Mar 2, 2011

Site.Master file contains

<ul id="nav">
<% Html.RenderAction("Menu", "ShoppingCart"); %>
</ul>
[ChildActionOnly]
public ActionResult Menu()
{
// for to geenrate menu ?
return ????
}

How to generate hierarchical menu below in Menu method from database data ? Should I use stringbuilder or is there better way ?

Resulting html shoudl look like:

[Code]....

View 64 Replies

Web Forms :: Dynamically Generate A Menu?

Nov 11, 2010

I have a 3 layer aps.net application (DAL, BLL,PL)

I wanted to create a horizantal menu and then to populate/enable/disable the items of the menu depending on the user has permision of a specific form/page or not.

The backend/ data base work is complete. I give rights to a user/role on a specific page and I

also develope functions/procedures to check the user rights/retrieve all pages on which the user has rights.

The missing part is the front end, How I can implement this on the front end?

If I got some standard way, I will immplement it in all my future asp.net apps, As most of our apps have some menu and we want to display mentu items to the user depneding on the rights.

I may want to clear one thing here that I want a horizantal menu but there is no horizantal menu in aps.net tree view.

View 3 Replies

JQuery :: Generate Runtime Menu?

Jul 29, 2010

I have to create a menu at runtime.How can i achieve it using Jquery and MVC 2.

View 1 Replies

Visual Studio 2008 Generate Top Navigation Menu?

Dec 21, 2010

I came across this site and like the top nav menu [URL] can visual studio 2008 generate such a menu like that. Moreover, what about if I want to apply security on what to show in the menu. For instance, I will have 3 departments ( Finance, Accounting and Marketing ) each department has its own apsx page. Depending on role, I need to show / not show a page under each department. How can I enforce such thing.

View 1 Replies

Web Forms :: How To Generate List Menu Form The DataTable

Aug 31, 2010

This is my c# code.

[Code]....

View 5 Replies

C# - Already An Open DataReader Associated With This Command - When I'm Not Using Datareader

Jul 28, 2010

I am getting an error that an open DataReader associated with this Command, when I'm not using datareader(though probably executereader() is the same thing) how would I close this if I don't have a datareader present?

using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand("spSelectAllTypes",conn);
cmd.CommandType = CommandType.StoredProcedure;
[code]...

I just want to be able to databind a bunch of dropdownlist in one open connection. (before I had multiple open and closes for each control)

View 2 Replies

Forms Data Controls :: Displaying Correct Result Inside DropDownList From LINQ Query Result

Jul 1, 2010

I have this ListView that has a Drop Down List.Everything works fine (I think/hope) except that the drop down list are not showing its result correctly.This is the code.

Front-End
[Code]....

The code behind consist of the page_load and the ItemDataBound
[Code]....

View 3 Replies

Linq To XML - Getting Correct Query Result, But It's Buried Deep In The Result Var?

Mar 1, 2011

I'm having a problem with my Linq to XML query. I'm getting the result data I want, but it's nested so deep that there must be a better way.Here is my XML:

[Code]....

I'm trying to get a list (simple string[]) of all Item IDs where Category Names contains "Other".Here is my Linq:

[Code]....

[Code]....

Here is a snapshot of my result from Visual Studio:The results I want are there ("item100", "item400", "item500"), but buried so deeply in the results var.

How can I get the query to return a simple

string[] = { "item100", "item400", "item500" }

View 4 Replies

Delaring A String Thats Within A Loop Within Another Loop

Jan 14, 2010

Im stuck with declaring a string which is in a loop within another loop.

Dim CompanyDetails As String = ""
Dim CompanyRow As DataRow
For Each CompanyRow In newdt.Rows
CompanyDetails += CompanyRow(1) & " " & CompanyRow(0) & "<br/>"...

How can I get this to see the GetInfo as declared..... since its in a loop within a loop?

View 9 Replies

SQL Server :: Failed To Generate A User Instance - Only An Integrated Connection Can Generate

Dec 16, 2010

Windows 7 Ultimate 64bit Visual Studio 2008 Team System Using C# SQL Server 2005 Express Management Studio (Service Pack 3) By using Visual Studio 2008,I opened Server Explorer and tried to modify Database connection,i wanted to use SQL Authentication,I entered User name and Passwored after pressing OK button,i got the following... Error message Failed to generate a user instance of SQL Server.Only an integerated connection can generate a user instance.The connection will be closed.

View 4 Replies

Multiple Single-result Sql Server Stored Procedures Or Single Multple-result Stored Procedure?

Aug 9, 2010

Background: I use stored procedures exclusively for an ASP.NET application. I am using a DataReader to load a dataset object.

View 4 Replies

.net - Going Through A DataReader Twice?

Mar 30, 2011

I have the following code which does what it's supposed to do:

objSQLCommand = New SqlCommand("select * from table1", objSQLConnection)
objSQLCommand.Connection.Open()
objSQLDataReader = objSQLCommand.ExecuteReader()[code]....

But I need to loop through the objSQLDataReader 1 more time. How would I do that?

View 2 Replies

How Can Serialize A Datareader In Webservices

Mar 23, 2010

how we can serialize a datareader in webservices.

View 1 Replies

What Is The Difference Between DataSet And DataReader

Dec 1, 2010

What is the difference between DataSet and DataReader in Asp.net with Example..

View 11 Replies

How To Serialize The DataReader In Webservices

Mar 20, 2010

How to serialize the DataReader in webservices in asp.net?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved