Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 10th, 2003, 01:08 AM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Q:Read two rows from table

i wanna read two rows from a table inside a database and display in a text box.

2 fields in table
---------------
id topic
1stID this is first id
2ndID This is second id

ie.

if ID = "1stID"
   cell1.innertext = "this is first id"
end if
if ID = "2ndID"
   cell2.innertext = "this is second id"
end if

prob doesn't make any sense, but i wanna display 2 rows from a table. But what would i do in the SQL statement. i am able to retrieve the 2 rows i want. but how to make the cell in a html table display corresponding topics.

LegoMan

 
Old October 13th, 2003, 01:07 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default

hi, what do u mean by cell...? is it a text box?
Sorry, i very blurr to ur question...

Regards
life's Ng

 
Old October 13th, 2003, 02:15 AM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK. maybe i should make it simpler.

i want to display 2 fields from a table inside a database. each field being inside cells inside a table.

so i wanna find via the id.

does that make sense? i thought would have to do 2 sql statements to retrieve a listing then bind it to a rs.

 
Old October 13th, 2003, 08:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I am only learning aspx now so their may be a better solution but I was in the same situation last week.

I ended up putting an <asp:literal id="myLitControl"/> control in the table cell and then changed its Text attribute in my code behind.

Hope this helps

======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old October 14th, 2003, 01:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you have a reference to the table to which you want to add the cells you are able to do this dynamically. A table has got a Rows collection which enables you to add rows and rows has a Cells collection. A small example...
Code:
Table table = new Table();
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.Controls.Add(new LiteralControl("something"));
table.Rows.Add(row);
row.Cells.Add(cell);
[not tested]

This example shows how to build a table dynamically i C#; it adds a cell to a row, and add that row to the table. If you have a reference to the table on your page you can do the same.

Hope it helps

Jacob.










Similar Threads
Thread Thread Starter Forum Replies Last Post
How to move rows in a table bucky483 Javascript How-To 10 March 27th, 2017 12:57 AM
Read CSV file - Save Columns into Rows pintoo BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 August 20th, 2008 09:01 AM
How to associate table rows with hyperlink?[READ] user0b PHP How-To 1 July 30th, 2008 04:20 AM
Read all rows from text file shai505 C# 5 April 28th, 2006 09:37 PM
insert rows into the same table nik SQL Server 2000 1 October 26th, 2005 07:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.