Check The GridView Records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanagasetti
    New Member
    • Aug 2012
    • 3

    Check The GridView Records

    I have a 3 GridvViews one is To,another one is Cc and Bcc ,
    After enter the values to Grids,i want to save those Records.
    Now what is my question is ---at the time of saving Check the data is there in 3 Grids or not.

    ex:
    i insert records to To,but i'm not insert records to Cc,Bcc ,then it shows the "error enter atlest one record..." .I want like this for this i wrote Script function and call the Script in to Save button by using OnClientClick Property.

    Code:
    <JavaScript >
    function Validate() {
                var To = document.getElementById("<%= gvTo.ClientID %>");
                var Cc = document.getElementById("<%= gvCc.ClientID %>");
                var Bcc = document.getElementById("<%= gvBcc.ClientID %>");
     
    
                if (To.rows.length < 1 || Cc.rows.length < 1 || Bcc.rows.legth < 1) {
                    alert("please enter at least one record");
                }
                else {
                    alert("Continue..");
                }
            }
    </JavaScript>
  • Mudassir
    New Member
    • May 2012
    • 85

    #2
    well you can accomplish by taking a hidden field, and on row created and row deleted events of the grid view update the hidden filed say if the row is created increment the value of hidden field by 1 and when the row is deleted decrement it by 1. and now in javascript function you can do it as
    Code:
    <script type ="text/javascript">
    function Check(){
    var chk=(document.getElementById{"<%=myHiddenField.ClientID%>").value);
    if(chk=="" || chk=="0")
    {
    alert("Please Enter");
    return false;
    }
    else{
    return true;
    }
    }
    </script>
    ...
    Addan

    Comment

    Working...