Hi
I want No Data available in table should get removed when record is added. Below is the code.
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() });
document.getElementById('addRowBtn').addEventListener('click', function () {
// Get the table body
var tableBody = document.getElementById('tbldata').getElementsByTagName('tbody')[0];
// Get the values from the dropdown and file upload
var documentValue = document.getElementById('<%= ddlDocument.ClientID %>').value;
var documentText = document.getElementById('<%= ddlDocument.ClientID %>').options[document.getElementById('<%= ddlDocument.ClientID %>').selectedIndex].text;
var fileUpload = document.getElementById('<%= FileUploadIdentityProof.ClientID %>');
var fileName = fileUpload.value.split('\\').pop();
// Create a new row
var newRow = tableBody.insertRow();
// Insert cells and set their content
var cell1 = newRow.insertCell(0);
var cell2 = newRow.insertCell(1);
var cell3 = newRow.insertCell(2);
var cell4 = newRow.insertCell(3);
cell1.innerHTML = tableBody.rows.length; // Sr. No.
cell2.innerHTML = documentText; // Document
cell3.innerHTML = fileName; // File Name
cell4.innerHTML = ''; // Action
// Clear the file upload control
fileUpload.value = '';
});

Thanks
Naimish MakwanaPosted Sep 4, 2024, 5:46 AM
To ensure that the “No Data available” message is removed when a record is added to the table, you can add a check to remove any existing placeholder row before inserting the new row. Here’s how you can modify your JavaScript code to achieve this:
Here’s the updated code:
C# Code
JavaScript Code
This code will ensure that the “No Data available” message is removed as soon as a new row is added to the table. If you have any further questions or need additional help, feel free to ask
Thanks
Amit MohantyPosted Sep 4, 2024, 5:43 AM
Try the below code once.