Skip to content
Loading
Using Jquery should be able to add name email-id in the GRID
 
after that add the $(gridView).show(); in $(document).on("click", ".classAdd", function ()
  1. "text/javascript" >  
  2.     $(document).ready(function () {    
  3.         $(document).on("click"".classAdd"function() {    
  4.             $(gridView).show(); // add this line  
  5.                                 //on is used for getting click event for dynamically created buttons    
  6.         var rowCount = $('.data-contact-person').length + 1;  
  7.         var contactdiv = '' +  
  8.             ' + rowCount + '" class="f-name01">' + $("#textBox1").val() + '' +  
  9.             ' + rowCount + '" class="l-name01">' + $("#textBox2").val() + '' +  
  10.             ' + rowCount + '" class="email01">' + $("#textBox3").val() + '' +  
  11.             'Remove' +  
  12.             '';    
  13.             $('#maintable').append(contactdiv); // Adding these controls to Main table class    
  14.     });    
  15.     
  16.         $(document).on("click"".deleteContact"function() {    
  17.             $(this).closest("tr").remove(); // closest used to remove the respective 'tr' in which I have my controls     
  18.     });  
  19. });    
  20.   
If it hepls you then mark as an answer.
  • Amit, 
     
    How to clear the Text boxes after adding the values when we are adding to grid

     
     
    I am trying to use this

    function clrCtrl()
    {
    document.getElementById('ctl00_ContentPlaceHolder1_TextBox1').value = "";
    document.getElementById('ctl00_ContentPlaceHolder1_TextBox2').value = "";
    }


    but it is no working... 
  • Hi Amit,

    Hope you are doing good today!!
     
    Thank you for your response, Initially the grid is not to be open..
    When we are click event then only the grid should display..
     
     
  • Amit Mohanty
    Hey try this
    1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" %>  
    2.   
    3.   
    4. "http://www.w3.org/1999/xhtml">  
    5. "server">  
    6.     Demo  
    7.     "utf-8" />  
    8.     "viewport" content="width=device-width, initial-scale=1" />  
    9.     "stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />  
    10.     "https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">  
    11.     "http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js">  
    12.   
    13.   
    14.     "form1" runat="server">  
    15.         class="container">  
    16.             

      Basic Table

        
    17.               
    18.                 
    19.   
    20.                     
    21.   
    22.                 
    23.   
    24.                 
    25.   
    26.                     
    27.   
    28.                 
    29.   
    30.                 
    31.   
    32.                     
    33.   
    34.                 
    35.   
    36.                 
    37.   
    38.                     
    39.   
    40.                 
    41.   
    42.             
    43.   
    44.                         "textBox1" runat="server">  
    45.                     
    46.   
    47.                         "textBox2" runat="server">  
    48.                     
    49.   
    50.                         "textBox3" runat="server">  
    51.                     
    52.   
    53.                         "button" id="btnAdd" class="btn btn-xs btn-primary classAdd">Add More  
    54.                     
    55.   
    56.             class="table" id="maintable">  
    57.                   
    58.                       
    59.                         Firstname  
    60.                         Lastname  
    61.                         Email  
    62.                       
    63.                   
    64.                   
    65.                       
    66.                   
    67.               
    68.             "button" id="btnSubmit" class="btn btn-primary btn-md pull-right btn-sm">Submit  
    69.         
      
  •       
  •   
  •   
  • "text/javascript">  
  •     $(document).ready(function () {  
  •         $(document).on("click"".classAdd", function () {  
  •             //on is used for getting click event for dynamically created buttons  
  •             var rowCount = $('.data-contact-person').length + 1;  
  •             var contactdiv = '' +  
  •                 ' + rowCount + '" class="f-name01">' + $("#textBox1").val() + '' +  
  •                 ' + rowCount + '" class="l-name01">' + $("#textBox2").val() + '' +  
  •                 ' + rowCount + '" class="email01">' + $("#textBox3").val() + '' +  
  •                 'Remove' +  
  •                 '';  
  •             $('#maintable').append(contactdiv); // Adding these controls to Main table class  
  •         });  
  •   
  •         $(document).on("click"".deleteContact", function () {  
  •             $(this).closest("tr").remove(); // closest used to remove the respective 'tr' in which I have my controls   
  •         });  
  •     });  
  •   
  •