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
- protected void btnAdvance_Click(object sender, EventArgs e)
- {
- Hashtable hsh = (Hashtable)Session["documentHash"];
- Panel1.Visible = true;
- tbl = new Table();
- Panel1.Controls.Add(tbl);
- tbl.GridLines = GridLines.Both;
- int docListCount = AssocDocList.Items.Count;
- TableRow tr = new TableRow();
- TableCell tc1 = new TableCell();
- TableCell tc2 = new TableCell();
- TableCell tc3 = new TableCell();
- tc1.Controls.Add(new LiteralControl("Document Type ID"));
- tr.Cells.Add(tc1);
- tc2.Controls.Add(new LiteralControl("Document ID"));
- tr.Cells.Add(tc2);
- tc3.Controls.Add(new LiteralControl("Display Type"));
- tr.Cells.Add(tc3);
- tbl.Rows.Add(tr);
- for (int j = 0; j < docListCount; j++)
- {
- DropDownList ddl = new DropDownList();
- ddl.ID = "drop" + j;
- ddl.Items.Clear();
- ddl.Items.Add("PP");
- ddl.Items.Add("PD");
- ddl.Items.Add("DP");
- ddl.Items.Add("DD");
- TableRow r = new TableRow();
- for (int i = 0; i < 3; i++)
- {
- TableCell c = new TableCell();
- if (i == 0)
- c.Controls.Add(new LiteralControl(hsh[AssocDocList.Items[j].Text].ToString()));
- else if (i == 1)
- c.Controls.Add(new LiteralControl(AssocDocList.Items[j].Text));
- else
- c.Controls.Add(ddl);
- r.Cells.Add(c);
- }
- //Table1.Rows.Add(r);
- tbl.Rows.Add(r);
- //Session["tbl"] = Table1;
- }
- //Session["tbl"] = Table1;
- }
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
- protected void btnSave_Click(object sender, EventArgs e)
- {
- DocWizProjectControl pj = new DocWizProjectControl();
- pj.CreatedBy = "ADMIN";
- //Table table = new Table();
- //table = (Table) Session["tbl"];
- int rowCount = tbl.Rows.Count;
- for (int i = 0; i < rowCount; i++)
- {
- //string doc_type_id = tbl.Rows[i].Cells[0].Text;
- string document_name = tbl.Rows[i].Cells[1].Text;
- }
- }