Fetch Row contents of a table
-
14-07-2021 - |
Question
I am working on ASP.Net 1.1.
In a page I have table as :
<table id="dlInterior" Width="300" Runat="server" CellSpacing="0" CellPadding="0">
<tr>
<td id="inttd" vAlign="top" width="350" runat="server"></td>
</tr>
</table>
On Page load - I am adding rows to this table dynamically as :
public static void DisplayDecodedInfo(object[] decodedValues, HtmlTable tableToAdd)
{
try
{
if(decodedValues.Length > 0)
{
foreach(string item in decodedValues)
{
HtmlTableCell tdInterior = new HtmlTableCell();
HtmlTableCell tdInterior1 = new HtmlTableCell();
tdInterior1.Attributes.Add("Width","3%");
tdInterior1.Attributes.Add("Align","Center");
HtmlTableRow trInterior = new HtmlTableRow();
trInterior.Attributes.Add("Height","20px");
tdInterior.Attributes.Add("padding-left","2cm");
tdInterior.InnerHtml = "<b>*</b> " + item;
trInterior.Controls.Add(tdInterior1);
trInterior.Controls.Add(tdInterior);
tableToAdd.Controls.Add(trInterior);
}
}
}
}
Now On SAVE button click event of the page, I need to fetch these string values row by row .
Please suggest how is it possible.
Solution
Well you cannot just fetch the content of a HTML table from a server side script. So what should you do is also render hidden fields for data and on submit you can find it in Request.Form[]
.
OTHER TIPS
I would cache these decodedValues
in Session
or ViewState
and retrieve the array from there on postback if needed.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow