472,330 Members | 1,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 software developers and data experts.

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="introduction">Introduction Text</div>
<div id="welcome">Welcome Text</div>
<div id="notes">&nbsp;</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="introduction">var_introduction</div>
<div id="welcome">var_welcome</div>
<div id="notes">var_notes</div>

Where:
var_introduction = "Introduction 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="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Function dsContent(ByVal page As String, ByVal name As String) As
System.Data.DataSet
Dim connectionString As String =
System.Configuration.ConfigurationSettings.AppSett ings("connectionString")
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString )
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.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_page As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_page.ParameterName = "@page"
dbParam_page.Value = page
dbParam_page.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_page)
Dim dbParam_name As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_name.ParameterName = "@name"
dbParam_name.Value = name
dbParam_name.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_name)
Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
</script>
<html>
....

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

Nov 19 '05 #1
3 2042
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*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********@rogers.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********@rogers.com> wrote in message
news:RE********@rogers.com:
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*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********@rogers.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.*DELETE2SEND*com> wrote in message
news:mdmoura*NOSPAM*@gmail.*DELETE2SEND*com:
What do you mean?

Cheers,
Miguel

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

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*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********@rogers.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
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...
0
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...
3
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...
3
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...
5
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...
16
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...
2
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...
2
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...
1
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...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.