473,608 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with displaying dynamic Html Table control

Hey,

I have a Web Form with a drop down list, textbox, and search button.
When click the search button an SQL server database is queried fordata.
Once I have the data in a dataset I use the dataset to dynamically create a
Html Table control.

I want to display the table on another frame page (target="main") without
the web form controls (i.e. the textbox, search button, and dropdown list).
I just want the table displayed only on the new seperate frame page.

Problem 1 - The HTML Table does not display at all
Problem 2 - The original web form controls are displayed on the new page

When debug the correct data is retrieved from DB and the rows are populated.
But the table does not display.

In the following Code-Behind file example "maxrows" = 1 and "maxcolumns " = 8
------

protected System.Web.UI.H tmlControls.Htm lTable t1;
protected System.Web.UI.H tmlControls.Htm lSelect ddlSearch;
protected System.Web.UI.H tmlControls.Htm lInputText txtSearch;
protected System.Web.UI.H tmlControls.Htm lInputButton btnSearch;
try
{

sDa = new OleDbDataAdapte r(lSql,sConn);
sDa.Fill(ds, "Products") ;
}
catch(Exception ex)
{
Response.Write( "Problem filling DataSet " + ex.Message);
}

try
{

t1 = new HtmlTable();

int maxrows = 0;
int maxcolumns = 0;

maxrows = ds.Tables["Products"].Rows.Count;
maxcolumns = ds.Tables["Products"].Columns.Count;

int row = 0;

for( int i = 0; i < maxrows; i++)
{

HtmlTableRow r = new HtmlTableRow();
row = row + 1;

for( int j = 0; j < maxcolumns; j++)
{
HtmlTableCell c = new HtmlTableCell() ;

c.Controls.Add( new
LiteralControl( Convert.ToStrin g(ds.Tables["Products"].Rows[i][j])));
r.Cells.Add(c);
}
t1.Rows.Add(r);

}

t1.Visible = true;
ASPX File
------------

<body MS_POSITIONING= "GridLayout ">
<TABLE id="t1" bgcolor="silver " border="5" align="right" runat="server">
</TABLE>
<form id="Search" method="post" target="main" runat="server">
<SELECT id="ddlSearch" style="Z-INDEX: 101; LEFT: 35px; POSITION:
absolute; TOP: 37px" runat="server">
<OPTION value="Title" selected>Title</OPTION>
<OPTION value="Type">Ty pe</OPTION>
<OPTION value="Author"> Author</OPTION>
<OPTION value="Edition" >Edition</OPTION>
<OPTION value="Copyrigh t">Copyright </OPTION>
</SELECT>
<INPUT id="btnSearch" style="Z-INDEX: 102; LEFT: 318px; POSITION:
absolute; TOP: 38px" type="button" value="Search" runat="server">
<INPUT id="txtSearch" style="Z-INDEX: 103; LEFT: 130px; POSITION:
absolute; TOP: 37px" type="text" runat="server">

--
Al
Nov 19 '05 #1
3 3822
What I would do is create a normal form in html with the target set to the
frame and the action where you want to display the table. In this new page
you would be able to populate the dataset doing the SQL using the fields
passed in the Request.Form

<form name="forma" action="table.a spx" target="framena me">
<input type="text" name="text1" value="">
<select name="select1">
<option value="1">Optio n 1</option>
<option value="2">Optio n 2</option>
</select>
</form>

in table.aspx

you would build the SQL:

Dim sSql as String = "SELECT * FROM TABLE WHERE FIELD1 ='" &
Request.Form("t ext1") & "' AND FIELD2="& REquest.Form("s elect1")

With the sql you populate the dataset and create the output.
"Al Wilkerson" <ac***@comcast. net> wrote in message
news:zP******** ************@co mcast.com...
Hey,

I have a Web Form with a drop down list, textbox, and search button.
When click the search button an SQL server database is queried fordata.
Once I have the data in a dataset I use the dataset to dynamically create
a Html Table control.

I want to display the table on another frame page (target="main") without
the web form controls (i.e. the textbox, search button, and dropdown
list). I just want the table displayed only on the new seperate frame
page.

Problem 1 - The HTML Table does not display at all
Problem 2 - The original web form controls are displayed on the new page

When debug the correct data is retrieved from DB and the rows are
populated. But the table does not display.

In the following Code-Behind file example "maxrows" = 1 and "maxcolumns " =
8
------

protected System.Web.UI.H tmlControls.Htm lTable t1;
protected System.Web.UI.H tmlControls.Htm lSelect ddlSearch;
protected System.Web.UI.H tmlControls.Htm lInputText txtSearch;
protected System.Web.UI.H tmlControls.Htm lInputButton btnSearch;
try
{

sDa = new OleDbDataAdapte r(lSql,sConn);
sDa.Fill(ds, "Products") ;
}
catch(Exception ex)
{
Response.Write( "Problem filling DataSet " + ex.Message);
}

try
{

t1 = new HtmlTable();

int maxrows = 0;
int maxcolumns = 0;

maxrows = ds.Tables["Products"].Rows.Count;
maxcolumns = ds.Tables["Products"].Columns.Count;

int row = 0;

for( int i = 0; i < maxrows; i++)
{

HtmlTableRow r = new HtmlTableRow();
row = row + 1;

for( int j = 0; j < maxcolumns; j++)
{
HtmlTableCell c = new HtmlTableCell() ;

c.Controls.Add( new
LiteralControl( Convert.ToStrin g(ds.Tables["Products"].Rows[i][j])));
r.Cells.Add(c);
}
t1.Rows.Add(r);

}

t1.Visible = true;
ASPX File
------------

<body MS_POSITIONING= "GridLayout ">
<TABLE id="t1" bgcolor="silver " border="5" align="right" runat="server">
</TABLE>
<form id="Search" method="post" target="main" runat="server">
<SELECT id="ddlSearch" style="Z-INDEX: 101; LEFT: 35px; POSITION:
absolute; TOP: 37px" runat="server">
<OPTION value="Title" selected>Title</OPTION>
<OPTION value="Type">Ty pe</OPTION>
<OPTION value="Author"> Author</OPTION>
<OPTION value="Edition" >Edition</OPTION>
<OPTION value="Copyrigh t">Copyright </OPTION>
</SELECT>
<INPUT id="btnSearch" style="Z-INDEX: 102; LEFT: 318px; POSITION:
absolute; TOP: 38px" type="button" value="Search" runat="server">
<INPUT id="txtSearch" style="Z-INDEX: 103; LEFT: 130px; POSITION:
absolute; TOP: 37px" type="text" runat="server">

--
Al

Nov 19 '05 #2


Hey,

But I want the action (server code) to be done in the code-behind C#
file. I wanted to avoid using the <script> tag in the aspx file.

Otherwise, what you're saying I would build (using script tag) the
database query and dataset population, in the aspx file which also holds
a table, and then retreive the values from the aspx file (maybe passing
session variables) to the C# code-behind file to display the table.

It seems like your solution is the old HTML/ASP way, and not the .Net
way. Am I correct in this?

Thanks,

Al

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3
Hi,

From server side code, you cannot access a page on different frame. Hence,
you cannot show the html table in a different page or frame.

You can have two <div> tags, one with the search details and other you can
use it for inserting the html table. You can set the visibility of first div
off and display only the second div.

In your code,
t1.Visible = true;
after creating the html table, you need to add this to the page or a
control. If you second div id is "resulttabl e", you can add,

resulttable.Con trols.Add(t1);

This will insert the newly created html table in the div.
Saravanan K V

"Al Wilkerson" wrote:


Hey,

But I want the action (server code) to be done in the code-behind C#
file. I wanted to avoid using the <script> tag in the aspx file.

Otherwise, what you're saying I would build (using script tag) the
database query and dataset population, in the aspx file which also holds
a table, and then retreive the values from the aspx file (maybe passing
session variables) to the C# code-behind file to display the table.

It seems like your solution is the old HTML/ASP way, and not the .Net
way. Am I correct in this?

Thanks,

Al

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #4

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

Similar topics

55
4169
by: drhowarddrfine | last post by:
I'm working on a web site that could use some control using js but am concerned about what problems I may have with potential users having their js turned off. Has anyone had any serious problems with this sort of thing? I know some of these potential users are with big companies and am wondering if anyone had real problems with that.
3
2770
by: Rick | last post by:
I have an interesting problem when I run the following code in Netscape (7.02) vs. IE. This page works great in IE and all my controls bring up the validation summary dialog box if the required field is not filled out. However in Netscape NONE of the required field validations occurs at all in Netscape. The form is posting correctly because I can walk through the post back process. Any ideas why this is happening or how to fix it?
1
6340
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the dataset to dynamically create a Html Table control. I want to display the table on another frame page (target="main") without the web form controls (i.e. the textbox, search button, and dropdown list). I just want the table displayed only on the...
7
1883
by: Abraham Luna | last post by:
how do i stop the dynamic validators from breaking explorer if i use a dynamic validator and move to a different control it breaks explorer and i can type in the page when i'm not supposed to. thank you.
1
1264
by: Jeff | last post by:
Hey asp.net 2.0 I have a repeater control in my webpage (you see my code below). In this control's ItemDataBound event I set the ImageUrl of a Image object. My problem is that when I run this webpage it shows only 1 image... -the repeater displays 2 rows, but it's only the first row that displays the image...
2
17074
by: cbjewelz | last post by:
Hey all. So I'm having problems with cross browser alignments. I'm looking at Safari and Mozilla Firefox. I develop in Safari and so it looks perfect there however in Firefox my vertical alignments and div widths are off. It's as if firefox has a different definition of a pixel than safari. Here is the url: http://theprize.chemouni.com/testing.php. When you select the Option from the pull down, the first part of the form appears. Then when...
9
4556
by: Cogito | last post by:
My program builds several tables using inner HTML. All the tables are displayed only when the program terminates. How can I make it display one table at a time and then wait for a click before displaying the next table?
1
4187
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly? http://geekarama.co.uk/new_home.html here is the code for new_home.html and following that the CSS...
482
27531
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. what i am trying to display previously entered multiple fields. I am able to get my serial fields to display correctly, but i can not display my parts fields correctly. Currently this is what it does serial information 1 parts 1
0
8503
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...
1
8160
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8358
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6826
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
6017
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
5482
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
4036
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1339
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.