Solved

How to do validation for the grid?

Posted on 2013-01-04
2
209 Views
Last Modified: 2013-01-05
Hi,

Pls find the attached image.

I have 2 dropdowns (NewsSector, NewsSectorType). when i select values from these 2 dropdowns and click on Add button, it will add rows to grid. Here i need to do validation ie if user is trying to add the same row which is alreday existed then it has to show pop up message that "Please select another NewsSector and NewsSectorType as it is already existed".

can we do this validation in client side? If so, how?


Thanks,
validation.jpg
0
Comment
Question by:swathi111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
informaniac earned 500 total points
ID: 38745025
var gv = document.getElementById("gridViewID");

var exists = false;
var ddlNewsSector = document.getElementById("ddlNewsSector");
var ddlNewsSectorType = document.getElementById("ddlNewsSectorType");
for(var i = 1; i< gv.rows.length; i++)
{
      var  tr = gv.rows[i];
      var NewsSector = tr.cells[0];
      var NewsSectorType = tr.cells[1];
      
      if(NewsSector.innerHTML == ddlNewsSector.Items[ddlNewsSector.SelectedIndex].value
            && NewsSectorType.innerHTML == ddlNewsSectorType.Items[ddlNewsSectorType.SelectedIndex].value
        )
        {
            exists = true;
            break;
        }
}

if(exists == true)
{
      alert("Record already exists");
      return false;
}
else
       return true;

Open in new window

0
 

Author Comment

by:swathi111
ID: 38747624
I tried this. Its working perfect. Thanks for your code.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb.net convert long time to mm:ss 23 34
YouTube API get the Video Tags - vb.net 7 52
Blending HTML output from R Studio into a ASP.Net/C# project 4 52
asp.net repeater 2 38
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question