Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
2
Answers
Delete Row is not working in below code.
Nidhi Donga
5y
491
1
Reply
<%@ Page Language=
"C#"
AutoEventWireup=
"true"
CodeBehind=
"test_table_dynamic.aspx.cs"
Inherits=
"Test_captcha.test_table_dynamic"
%>
<!DOCTYPE html>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head runat=
"server"
>
<title></title>
<link href=
"Content/bootstrap.css"
rel=
"stylesheet"
/>
<script src=
"Scripts/jquery-3.0.0.js"
></script>
<script src=
"Scripts/bootstrap.js"
></script>
<style>
body {
font-family:
'lato'
, sans-serif;
}
.container {
max-width: 1000px;
margin-left: auto;
margin-right: auto;
padding-left: 10px;
padding-right: 10px;
}
h2 {
font-size: 26px;
margin: 20px 0;
text-align: center;
}
h2 small {
font-size: 0.5em;
}
.responsive-table li {
border-radius: 3px;
padding: 25px 30px;
display: flex;
justify-content: space-between;
margin-bottom: 25px;
}
.responsive-table .table-header {
background-color: #95A5A6;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 0.03em;
}
.responsive-table .table-row {
background-color: #ffffff;
box-shadow: 0px 0px 9px 0px rgba(0, 0, 0, 0.1);
}
.responsive-table .col-1 {
flex-basis: 5%;
}
.responsive-table .col-2 {
flex-basis: 50%;
}
.responsive-table .col-3 {
flex-basis: 25%;
}
.responsive-table .col-4 {
flex-basis: 25%;
}
@media all and (max-width: 767px) {
.responsive-table .table-header {
display: none;
}
.responsive-table li {
display: block;
}
.responsive-table .col {
flex-basis: 100%;
}
.responsive-table .col {
display: flex;
padding: 10px 0;
}
.responsive-table .col:before {
color: #6C7A89;
padding-right: 10px;
content: attr(data-label);
flex-basis: 50%;
text-align: right;
}
}
</style>
<script type=
"text/javascript"
>
function
addRow(tableID) {
var
table = document.getElementById(tableID);
var
rowCount = table.rows.length;
var
row = table.insertRow(rowCount);
var
colCount = table.rows[0].cells.length;
for
(
var
i = 0; i < colCount; i++) {
var
newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
//alert(newcell.childNodes);
switch
(newcell.childNodes[0].type) {
case
"text"
:
newcell.childNodes[0].value =
""
;
break
;
case
"checkbox"
:
newcell.childNodes[0].checked =
false
;
break
;
case
"select-one"
:
newcell.childNodes[0].selectedIndex = 0;
break
;
}
}
}
function
deleteRow(tableID) {
try
{
var
table = document.getElementById(tableID);
var
rowCount = table.rows.length;
for
(
var
i = 0; i < rowCount; i++) {
var
row = table.rows[i];
var
chkbox = row.cells[0].childNodes[0];
if
(
null
!= chkbox &&
true
== chkbox.checked) {
if
(rowCount <= 1) {
alert(
"Cannot delete all the rows."
);
break
;
}
table.deleteRow(i);
rowCount--;
i--;
}
}
}
catch
(e) {
alert(e);
}
}
</script>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<div
class
=
"container"
>
<h2>Sprinkler Irrigation Component's price <small></small></h2>
<ul
class
=
"responsive-table"
>
<li
class
=
"table-row"
>
<div
class
=
"col col-1"
data-label=
"Job Id"
>Email:</div>
<div
class
=
"col col-2"
data-label=
"Customer Name"
>
<asp:TextBox CssClass=
"form-control"
ID=
"c_email"
placeholder=
"Email"
runat=
"server"
></asp:TextBox>
</div>
<div
class
=
"col col-3"
data-label=
"Amount"
></div>
</li>
</ul>
</div>
<div
class
=
"container"
>
<ul
class
=
"responsive-table"
>
<li
class
=
"table-row"
>
<div
class
=
"col col-1"
data-label=
"Job Id"
>Nozzle</div>
<div
class
=
"col col-2"
>
<table id=
"dataTable"
class
=
"table-bordered table-hover table-striped table"
>
<tr>
<td>
<input type=
"checkbox"
name=
"chk"
/></td>
<td>
<asp:TextBox ID=
"TextBox1"
runat=
"server"
type=
"text"
placeholder=
"LPH"
></asp:TextBox></td>
<td>
<asp:TextBox ID=
"TextBox2"
runat=
"server"
type=
"text"
placeholder=
"RS./unit"
></asp:TextBox></td>
</tr>
</table>
</div>
<div
class
=
"col col-3"
></div>
<div
class
=
"col col-4"
>
<input type=
"button"
class
=
"btn btn-danger active"
value=
"Add Row"
onclick=
"addRow('dataTable')"
/><hr />
<input type=
"button"
class
=
"btn btn-info active"
value=
"Delete Row"
onclick=
"deleteRow('dataTable')"
/>
</div>
</li>
</ul>
</div>
</form>
</body>
</html>
In the above code i can insert the textbox by hitting add row button but delete row button is not working
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How to implement Telerik Control asp.net Application?
Session in web api.