473,769 Members | 4,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Table Problem C#

20 New Member
hi,
I have a problem regarding the retrieval of data from a table.
Here's is what I am doing.
I have a created a table and from added the rows and columns and also data dynamically from the code in one of the function. Now I need to access that table and data on a button click, i.e. when a user clicks button I must be able to get the table information cell-wise. I have written the following code and when the user clicks the button all I get is the row count (i.e. no. of rows in the table are correct) but I cannot retrieve the cell information (or I have to say they are all empty). I have also tried to put the table into one Session but it also returned the same result. So is there any way this can be done. Does anyone has any idea about this.
Help required urgently

Looking forward to your support
Thanks

Inserting into table at button click

Expand|Select|Wrap|Line Numbers
  1. protected void btnAdvance_Click(object sender, EventArgs e)
  2.     {
  3.         Hashtable hsh = (Hashtable)Session["documentHash"];        
  4.         Panel1.Visible = true;
  5.         tbl = new Table();
  6.         Panel1.Controls.Add(tbl);
  7.         tbl.GridLines = GridLines.Both;
  8.         int docListCount = AssocDocList.Items.Count;
  9.         TableRow tr = new TableRow();
  10.         TableCell tc1 = new TableCell();
  11.         TableCell tc2 = new TableCell();
  12.         TableCell tc3 = new TableCell();
  13.         tc1.Controls.Add(new LiteralControl("Document Type ID"));
  14.         tr.Cells.Add(tc1);
  15.         tc2.Controls.Add(new LiteralControl("Document ID"));
  16.         tr.Cells.Add(tc2);
  17.         tc3.Controls.Add(new LiteralControl("Display Type"));
  18.         tr.Cells.Add(tc3);
  19.         tbl.Rows.Add(tr);
  20.         for (int j = 0; j < docListCount; j++)
  21.         {
  22.             DropDownList ddl = new DropDownList();
  23.             ddl.ID = "drop" + j;
  24.             ddl.Items.Clear();
  25.             ddl.Items.Add("PP");
  26.             ddl.Items.Add("PD");
  27.             ddl.Items.Add("DP");
  28.             ddl.Items.Add("DD");
  29.             TableRow r = new TableRow();            
  30.             for (int i = 0; i < 3; i++)
  31.             {
  32.                 TableCell c = new TableCell();
  33.                 if (i == 0)
  34.                     c.Controls.Add(new LiteralControl(hsh[AssocDocList.Items[j].Text].ToString()));
  35.                 else if (i == 1)
  36.                     c.Controls.Add(new LiteralControl(AssocDocList.Items[j].Text));
  37.                 else
  38.                     c.Controls.Add(ddl);                    
  39.  
  40.                 r.Cells.Add(c);
  41.             }
  42.             //Table1.Rows.Add(r);
  43.             tbl.Rows.Add(r);
  44.             //Session["tbl"] = Table1;
  45.         }
  46.         //Session["tbl"] = Table1;
  47.     }
Retriving the table information on this button click to save in the DB
Gives header information as it is already in .aspx page but not the cell information added from the above button click

Expand|Select|Wrap|Line Numbers
  1.  protected void btnSave_Click(object sender, EventArgs e)
  2.     {
  3.         DocWizProjectControl pj = new DocWizProjectControl();
  4.         pj.CreatedBy = "ADMIN";
  5.         //Table table = new Table();
  6.         //table = (Table) Session["tbl"];
  7.         int rowCount = tbl.Rows.Count;
  8.         for (int i = 0; i < rowCount; i++)
  9.         {
  10.             //string doc_type_id = tbl.Rows[i].Cells[0].Text;
  11.             string document_name = tbl.Rows[i].Cells[1].Text;
  12.         }
  13.     }
Mar 7 '08 #1
3 1878
mylog
20 New Member
hi,
I have a problem regarding the retrieval of data from a table.
Here's is what I am doing.
I have a created a table and from added the rows and columns and also data dynamically from the code in one of the function. Now I need to access that table and data on a button click, i.e. when a user clicks button I must be able to get the table information cell-wise. I have written the following code and when the user clicks the button all I get is the row count (i.e. no. of rows in the table are correct) but I cannot retrieve the cell information (or I have to say they are all empty). I have also tried to put the table into one Session but it also returned the same result. So is there any way this can be done. Does anyone has any idea about this.
Help required urgently

Looking forward to your support
Thanks

Inserting into table at button click

Expand|Select|Wrap|Line Numbers
  1. protected void btnAdvance_Click(object sender, EventArgs e)
  2.     {
  3.         Hashtable hsh = (Hashtable)Session["documentHash"];        
  4.         Panel1.Visible = true;
  5.         tbl = new Table();
  6.         Panel1.Controls.Add(tbl);
  7.         tbl.GridLines = GridLines.Both;
  8.         int docListCount = AssocDocList.Items.Count;
  9.         TableRow tr = new TableRow();
  10.         TableCell tc1 = new TableCell();
  11.         TableCell tc2 = new TableCell();
  12.         TableCell tc3 = new TableCell();
  13.         tc1.Controls.Add(new LiteralControl("Document Type ID"));
  14.         tr.Cells.Add(tc1);
  15.         tc2.Controls.Add(new LiteralControl("Document ID"));
  16.         tr.Cells.Add(tc2);
  17.         tc3.Controls.Add(new LiteralControl("Display Type"));
  18.         tr.Cells.Add(tc3);
  19.         tbl.Rows.Add(tr);
  20.         for (int j = 0; j < docListCount; j++)
  21.         {
  22.             DropDownList ddl = new DropDownList();
  23.             ddl.ID = "drop" + j;
  24.             ddl.Items.Clear();
  25.             ddl.Items.Add("PP");
  26.             ddl.Items.Add("PD");
  27.             ddl.Items.Add("DP");
  28.             ddl.Items.Add("DD");
  29.             TableRow r = new TableRow();            
  30.             for (int i = 0; i < 3; i++)
  31.             {
  32.                 TableCell c = new TableCell();
  33.                 if (i == 0)
  34.                     c.Controls.Add(new LiteralControl(hsh[AssocDocList.Items[j].Text].ToString()));
  35.                 else if (i == 1)
  36.                     c.Controls.Add(new LiteralControl(AssocDocList.Items[j].Text));
  37.                 else
  38.                     c.Controls.Add(ddl);                    
  39.  
  40.                 r.Cells.Add(c);
  41.             }
  42.             //Table1.Rows.Add(r);
  43.             tbl.Rows.Add(r);
  44.             //Session["tbl"] = Table1;
  45.         }
  46.         //Session["tbl"] = Table1;
  47.     }
Retriving the table information on this button click to save in the DB
Gives header information as it is already in .aspx page but not the cell information added from the above button click

Expand|Select|Wrap|Line Numbers
  1.  protected void btnSave_Click(object sender, EventArgs e)
  2.     {
  3.         DocWizProjectControl pj = new DocWizProjectControl();
  4.         pj.CreatedBy = "ADMIN";
  5.         //Table table = new Table();
  6.         //table = (Table) Session["tbl"];
  7.         int rowCount = tbl.Rows.Count;
  8.         for (int i = 0; i < rowCount; i++)
  9.         {
  10.             //string doc_type_id = tbl.Rows[i].Cells[0].Text;
  11.             string document_name = tbl.Rows[i].Cells[1].Text;
  12.         }
  13.     }

Doesn't anyone know what the problem is with this code and why I am failing to get the required output? Please help needed greatly.
Mar 9 '08 #2
kenobewan
4,871 Recognized Expert Specialist
If I was going to do this I would probably populate the table in the page load and then only make the panel visble on the button click to show the results. HTH.
Mar 9 '08 #3
mylog
20 New Member
That may not be possible as I need to generate table depending upon the number of lists in a listbox the user selects and then get the values generated on that table. So any other idea, please
But thanks for trying.
Mar 10 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
6594
by: Gaz | last post by:
Hi, I need to have a table nested within another table. The tables are alongside each other visually speaking, and the nested table (on the right) can vary in size. My problem is that when the nested table has more rows than the first table, the first table (on the left) pads out its rows so that the table matches the height of the nested table. I don't want this it happen.. I just want the nested table to be longer than the first...
61
24503
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will 'stretch'</td> <td valign="top" width="300">some data that won't 'stetch'</td> </tr> </table>
3
11383
by: Terrence Brannon | last post by:
I don't know what Postgres considers a relation and had no intention of creating one when piping my schema to it... I always DROP TABLE before CREATE TABLE, so here are the ERRORS emitted when building the database: 3:ERROR: table "country" does not exist 6:ERROR: table "customer" does not exist 11:ERROR: table "product" does not exist 15:ERROR: table "license" does not exist 19:ERROR: table "enduser" does not exist 24:ERROR: ...
4
15839
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
4
548
by: Simone Battagliero | last post by:
I wrote a program which inserts and finds elements in an hash table. Each element of the table is a dinamic list, which holds all elements having the same hash value (calculated by an int hashFunction(char *key, int elements) ), so the table is an array of dynamic lists. The version of the program I've attached to this message works fine; but it's the result of an accurate debugging. I discovered that my problems consisted in just 4 lines...
117
18575
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of elements in the HTML to get everything just right. When you consider the class attribute on the DIV elements, there's not much size savings anymore for using DIV. There are other disadvantages to not using TABLE/TR/TD, such as the lack of ability...
76
272545
MMcCarthy
by: MMcCarthy | last post by:
Normalisation is the term used to describe how you break a file down into tables to create a database. There are 3 or 4 major steps involved known as 1NF (First Normal Form), 2NF (Second Normal Form), 3NF (Third Normal Form) and BCNF (Boyce-Codd Normal Form). There are others but they are rarely if ever used. A database is said to be Normalised if it is in 3NF (or ideally in BCNF). These steps are descibed as follows: Note: When attribute...
7
4827
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the expandable row, the hidden row is made visible with css. The problem is when i sort the rows, the hidden rows get sorted as well which i don't want and want to be moved (while sorting) relative to their parent rows. The following is my complete html code...
5
3846
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big table, we try separate this big table into twelve tables and create a view
5
4956
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html Here is some jquery js that I think...
0
9423
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
10212
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
10047
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...
1
9995
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
9863
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
8872
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...
0
5304
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...
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.