Hi
I have below code-behind code. I want to add rows on click of addrowbtn. How to get values.
StringBuilder htmlTable = new StringBuilder();
htmlTable.Append("");
htmlTable.Append("Sr. Document File Name Action ");
htmlTable.Append("");
htmlTable.Append("");
htmlTable.Append("
");
PlaceHolderTable0.Controls.Add(new Literal { Text = htmlTable.ToString() });
Documents Info
*
<%--Select Document --%>
10th Certificate
Aadhaar Card
*
Thanks
Naimish MakwanaPosted Sep 4, 2024, 4:33 AM
To add rows to your table on the click of the “Add” button and retrieve the values from the dropdown and file upload controls, you can use JavaScript to handle the button click event and update the table dynamically. Here’s how you can do it:
Here’s an example of how you can achieve this:
JavaScript Code
Add this script to your page:
Explanation
Update Your ASP.NET Code
Ensure your ASP.NET controls have the correct IDs and runat attributes:
This approach uses JavaScript to dynamically update the table on the client side, making the user experience smoother without requiring a postback to the server. If you need to persist the data on the server, you can handle that in your code-behind during a form submission.
Tahir AnsariPosted Sep 4, 2024, 4:30 AM
Hi Ramco,
You need to set the button's OnClick property to point to the event handler in the code-behind.
Below is the code-behind that handles adding the row and dynamically generating the table