473,546 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with Dynamic Html Table control generation

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">

Thanks,

--
Al

--
Al
Nov 19 '05 #1
1 6338
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.

"Al Wilkerson" wrote:
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">

Thanks,

--
Al

--
Al

Nov 19 '05 #2

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

Similar topics

11
4712
by: Marco Loskamp | last post by:
Dear list, I'm trying to dynamically generate functions; it seems that what I really want is beyond C itself, but I'd like to be confirmed here. In the minimal example below, I'd like to create content to put at the address pointed to by f. In particular, I'd like to avoid/replace the memcpy line. Possible application (inspired by Paul...
7
3565
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the same way like regular input fields can. strForm = "<form name=""myForm"" runat=""server"">" & vbCrLf strForm += "<asp:button name=""myName"" .......
4
3294
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just for the controls and not for the form itself. What I am trying to achieve is to create an entire form (including controls)
0
1463
by: Venus | last post by:
Hello, After trying some ways to do it I wanted to use something like the code below but for some reason is not working (I have to generate the entire form dynamically (not only the controls)): Can anyone make any suggestions on how to do it ? Thanks
3
3821
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...
5
2054
by: Rich S | last post by:
I created this neat little .net site which tracks the inventory of my little widge company giving me real time inventory counts and whatnot. It uses your standard code that calls a stored procedure and loads up a datagrid and works really well. It occurred to me that since my database inventory is only updated once per day at 6:30 am having...
5
3151
by: pittendrigh | last post by:
There must be millions of dynamically generated html pages out there now, built by on-the-fly php code (and jsp, perl cgi, asp, etc). Programatic page generation is transparently useful. But querying a database, negotiatinig lots of if-then-else logic and echo'ing html code out on port 80 every time a page is requested has to be a huge...
0
5276
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all the days in the week with dates and textboxes to fill in some data. row 1: question
7
2362
by: dino d. | last post by:
Hi- I want to create a dynamic image with areas so that when the user clicks different areas, the user jumps to those pages. The problem is, I can't seem to figure out how to do this efficiently. Suppose I have a table,items in a database: itemid description count So, basically, I want to create an image that has 3 ovals,...
0
7504
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
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...
0
7694
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. ...
0
7947
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...
0
7792
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...
0
5080
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...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
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
0
747
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...

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.