Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my Page i want to move the items from 'ListBox' to 3 'GridView' Controls ,one for To ,another for Cc & 3rd one for Bcc and then i create one Button for saving purpose.I move the members from ListBox to GridView and then to Save the data.

Now my question is I enter To values, but I'm not entered Cc,Bcc values and then Click on Save means it show some error message, u must enter atleast one record..?

for that i'm using RequiredField Validator for checking purpose,but in ControlToValidate property GridView id is not appeared how to check that Condition,plz help me...

Thanks
Posted
Comments
AshishChaudha 3-Aug-12 3:24am    
What you have done so far??? and where you are getting stuck?

1 solution

it is better to use javascript validations in this case.

ad this to your save button
OnClientClick ="return javascriptfn_name()"


and check the required fields using javascript function.
if any field is blank return false else return true from javascript funtion.

C#
function Validate() {
             var cc = document.getElementById("dynamic id of cc");
             var bcc= document.getElementById("dynamic id of bcc");
             if (cc.length < 1||bcc.length < 1) {
                return false;
             }
             else {
                 return true;
             }
         }
 
Share this answer
 
Comments
naveensanagasetti 3-Aug-12 5:35am    
I try ur code but i'm getting like this type of error

I wrote code like this

function Validate() {
var To = document.getElementById("gvTo");
var Cc = document.getElementById("gvCc");
var Bcc = document.getElementById("gvBcc");
if (To.length < 1 || Cc.length < 1 || Bcc.length < 1)
{
return false;
}
else
{
return true;
}
}


<asp:Button ID="btnSAVE" runat="server" Font-Bold="True" ForeColor="#6600FF"
Text="Save" OnClick="btnSAVE_Click" ToolTip="Save" ValidationGroup="Save"
Width="49px" önClientClick="Validate()" />

error:

Microsoft JScript runtime error: Object expected

Plz help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900