473,729 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display N records from a database in some Div's? Thanks.

Hello,

In a database table named t_content I have the following records:

id page name content
1 index introduction
Introduction Text
2 index welcome Welcome Text

3 index notes
4 contacts address Mailing Address

In index.aspx I want to display the content text from records 1, 2 and 3
in three existing div's. Something as:
<div id="introductio n">Introduct ion Text</div>
<div id="welcome">We lcome Text</div>
<div id="notes">&nbs p;</div> << "&nbsp;" is used when content is
empty.

As far as I understand I should retrieve all the fields which
page="index".

Then i should create N variables such as:
var_ { [name] from record 1} = { [content] from record 1}
var_ { [name] from record 2} = { [content] from record 2}
....

For the table example it would become something as:
<div id="introductio n">var_introduc tion</div>
<div id="welcome">va r_welcome</div>
<div id="notes">var_ notes</div>

Where:
var_introductio n = "Introducti on Text"
var_welcome = "Welcome Text"
var_notes = "&nbsp;"

Is my plan the right way to do something like this?
Can someone help me out in doing this?

I had created a dataset (See the end of post) from my table where I
filter a certain page where @page = ... and @name = ....
It's working fine. Now I need to change this to have something as I
described.

Thank You,
Miguel

Here is my dataset:

ASPX

....
<% @Import Namespace="Syst em.Data" %>
<% @Import Namespace="Syst em.Data.SqlClie nt" %>
<script runat="server">
Function dsContent(ByVal page As String, ByVal name As String) As
System.Data.Dat aSet
Dim connectionStrin g As String =
System.Configur ation.Configura tionSettings.Ap pSettings("conn ectionString")
Dim dbConnection As System.Data.IDb Connection = New
System.Data.Ole Db.OleDbConnect ion(connectionS tring)
Dim queryString As String = "SELECT [t_content].* FROM
[t_content] WHERE (([t_content].[page] = @page) AND ([t_content].[name]
= @name))"
Dim dbCommand As System.Data.IDb Command = New
System.Data.Ole Db.OleDbCommand
dbCommand.Comma ndText = queryString
dbCommand.Conne ction = dbConnection
Dim dbParam_page As System.Data.IDa taParameter = New
System.Data.Ole Db.OleDbParamet er
dbParam_page.Pa rameterName = "@page"
dbParam_page.Va lue = page
dbParam_page.Db Type = System.Data.DbT ype.String
dbCommand.Param eters.Add(dbPar am_page)
Dim dbParam_name As System.Data.IDa taParameter = New
System.Data.Ole Db.OleDbParamet er
dbParam_name.Pa rameterName = "@name"
dbParam_name.Va lue = name
dbParam_name.Db Type = System.Data.DbT ype.String
dbCommand.Param eters.Add(dbPar am_name)
Dim dataAdapter As System.Data.IDb DataAdapter = New
System.Data.Ole Db.OleDbDataAda pter
dataAdapter.Sel ectCommand = dbCommand
Dim dataSet As System.Data.Dat aSet = New System.Data.Dat aSet
dataAdapter.Fil l(dataSet)
Return dataSet
End Function
</script>
<html>
....

Web.Config
....
<appSettings>
<add key="connection String" value="Provider =Microsoft.Jet. OLEDB.4.0;
Ole DB Services=-4; Data Source=C:\db.md b" />
</appSettings>

Nov 19 '05 #1
3 2094
"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in news:
#z************* *@TK2MSFTNGP12. phx.gbl:
As far as I understand I should retrieve all the fields which
page="index".

Then i should create N variables such as:
var_ { [name] from record 1} = { [content] from record 1}
var_ { [name] from record 2} = { [content] from record 2}


Why not just loop your dataset and output?

No need for so many variables.

--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2
What do you mean?

Cheers,
Miguel

"Lucas Tam" <RE********@rog ers.com> wrote in message
news:RE******** @rogers.com:
"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in news:
#z************* *@TK2MSFTNGP12. phx.gbl:

As far as I understand I should retrieve all the fields which
page="index".

Then i should create N variables such as:
var_ { [name] from record 1} = { [content] from record 1}
var_ { [name] from record 2} = { [content] from record 2}

Why not just loop your dataset and output?

No need for so many variables.

--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Nov 19 '05 #3
Hi,

I think I can't use the dataset itself because I will not know which
record I need to use in each div. So I believe by using variables which
identify each record is maybe the best way (OR NOT?):

var_ { [name] from record 1} = { [content] from record 1}

So I think maybe I should create these variables from the dataset? What
do you think?

Something like:

For i = 1 to N < N is the number of rows of the
dataset.
if content(i) is empty then
var_[name(i)]="&nbsp;"
else
var_[name(i)]=[content)i)]
endif
end

Then in the div I should use something like:
<%# var_name %> ????

My problem is how to create these 2 pieces of code as I never done
something like this in ASP.NET.

Thanks,
Miguel

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:mdmoura*NO SPAM*@gmail.*DE LETE2SEND*com:
What do you mean?

Cheers,
Miguel

"Lucas Tam" <RE********@rog ers.com> wrote in message
news:RE******** @rogers.com:

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in news:
#z************* *@TK2MSFTNGP12. phx.gbl:

As far as I understand I should retrieve all the fields which
page="index".

Then i should create N variables such as:
var_ { [name] from record 1} = { [content] from record 1}
var_ { [name] from record 2} = { [content] from record 2}


Why not just loop your dataset and output?

No need for so many variables.

--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
3157
by: Mat | last post by:
<div id="container"> <div id="main"> <div id="header"> <p class="Address">123 Fake Street, </p> <p class="City">Crazy City, </p> <p class="Province">Ontario </p> <p class="PostalCode">H0H 0H0</p> <p class="Telephone">Telephone: 555-1234 </p> <p class="Fax">Fax: 555-4321</p> </div>
0
1552
by: Angelos | last post by:
Hello, I have the folowing code looping thru a result set from the Database and displaying a list of products. I want to use CSS to display 3 products for each line ... or any number of products that will fit in a line and look nice. So from the php side How can I do something for every 3 records e.x every 3 records echo "<ul>". Without any CSS it will display them vertically....
3
5401
by: Kai Zhang | last post by:
I am trying to display some database records in datagrid using dataset. the records need to be displayed are couple of thousands, but the records in database that the SQL query needs to exam are more than 70 thousand, and it is really slow to get the dataset ready to populate the datagrid. I am sure there are solutions on this issue, but I just don't know :-( Can anybody point me out any good solution to minimize the time used to...
3
3126
by: Bob Sanderson | last post by:
I am trying to create a form for a MySQL database similar to a spreadsheet. The idea is to display a list of records, with the last line of the list being an input form. When the user enters data in the form and hits the submit button, the data is entered and the form is reloaded with the new data displayed and another input form becomes the last line. Example --- Before entering new data
5
1975
by: CES | last post by:
All, I was hoping that someone might be able to help me with a few questions on Aligning Block Elements properly... Basically I have a row that has a fixed width of 900px. Within the row their is a <Divthat I want to align to the Right hand side of the <Div id=” Container “>. That div <Div id=”items”needs to be able to expand and contract based on the amount of text that is held within the <p id="p1">. This example is as close as I can...
16
3495
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record in a hidden field) I wish the user to be able to edit the data in the table, so I have extracted the records into hiddenfield, textareas, dropdown list and checkbox so that they can make changes. I named these elements as arrays and wish to run an...
2
12018
by: j.m.osterman | last post by:
I haven't found exactly what I've been trying to do. All I am trying to do for now is just display usernames from Active Directory into a ListBox control on a page. I have found some code however that will just capture a Full Name from Text Box and display information from the Active Directory into a DataTable. I will display that code below.
2
1561
by: DavidOwens | last post by:
<form action="do.php" method="post"> <?php /* create table users (id int, staffid int, region varchar(20), firstname varchar(20), surname varchar(20)); insert into users values(1,1,'region1','John', 'Doe'),(2,2,'region1','Pete', 'Mackay'); create table stores (name varchar(10)); insert into stores values('Name1'),('Name2'),('Name3'),('Name4'),('Na me5'),('Name6'); */ $con = mysql_connect("localhost","root","password");
1
1755
by: jasone | last post by:
Hi all, ive got a search function running on a database, the action performed by the form is shown below, within the 'else' statement i would like to show roughly 5 random rows from the sql table (alternative products) if you like. please find below the script im currently running for the search, the else statment just shows 'no results found' message at the moment. many thanks in advance for any who can help: <table width="40%"...
0
8763
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9284
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8151
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4528
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.