Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Validation Between Controls

Reply
Thread Tools

Validation Between Controls

 
 
DS
Guest
Posts: n/a
 
      11-17-2005
I have a datagrid with several fields with textboxes and drop downs. I
want to be able to validate the drop down field in one column to only
be required if the textbox field in another column has data. Does
anyone know how to do this?
I tried to use the compare validator and the custom validator but can't
figure out how to reference the control from the other column.
Any help would be greatly appreciated.
Thanks,
Deidre

 
Reply With Quote
 
 
 
 
Rick
Guest
Posts: n/a
 
      11-17-2005
hi DS,i have the same situation
i have a gridview with 6 cols, i need to validate col #3, so i used a
rangevalidator control, but the min and max range is different for each row,
so i need to change maxrange and minrange each time user select a row, i
converted the col #3 in Templatefield and then add a Rangevalidator to
validate its contents

but i dont know how to reference the control because its inside col#3 and
col#3 properties doesn't display any known control name (Rangevalidator)


"DS" <(E-Mail Removed)> escribió en el mensaje
news:(E-Mail Removed) oups.com...
>I have a datagrid with several fields with textboxes and drop downs. I
> want to be able to validate the drop down field in one column to only
> be required if the textbox field in another column has data. Does
> anyone know how to do this?
> I tried to use the compare validator and the custom validator but can't
> figure out how to reference the control from the other column.
> Any help would be greatly appreciated.
> Thanks,
> Deidre
>



 
Reply With Quote
 
 
 
 
Rick
Guest
Posts: n/a
 
      11-18-2005
i've solved it at last with help of Bug_Bugger at
http://forums.asp.net/1116631/ShowPost.aspx

Bug_Bugger says:

Implement RowDataBound event, in it use FindControl to locate the
appropriate controls and set the values

so i did this

protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)

{

// Find control on page.


RangeValidator myControl1 = (RangeValidator) e.Row.FindControl("RngVal");
//RngVal is my control name

//original code was Control myControl1 .... but i changed it to the control
type i need, in this case RangeValidator

if (myControl1 != null)

{

// Get control's parent.

Control myControl2 = myControl1.Parent;

myControl1.MaximumValue = "50"; // i changed this value

myControl1.MinimumValue = "40"; // and this

Response.Write("Parent of the text box is : " + myControl2.ID); // this text
shows control's parent

}

else

{

Response.Write("Control not found");

}

}



and works!!!!

"DS" <(E-Mail Removed)> escribió en el mensaje
news:(E-Mail Removed) oups.com...
>I have a datagrid with several fields with textboxes and drop downs. I
> want to be able to validate the drop down field in one column to only
> be required if the textbox field in another column has data. Does
> anyone know how to do this?
> I tried to use the compare validator and the custom validator but can't
> figure out how to reference the control from the other column.
> Any help would be greatly appreciated.
> Thanks,
> Deidre
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
where is the validation occurs for validation controls baroque Chou ASP .Net 4 01-24-2006 03:32 PM
What's the difference between HTML controls and the basic web controls? Alan Silver ASP .Net 8 01-24-2005 06:39 PM
Page appears to fail validation even though it has no validation controls =?Utf-8?B?ZGh1cndpdHo=?= ASP .Net 1 04-10-2004 07:37 AM
ASP.NET Web Forms Validation Controls are Server-Side or Client-Side Validation? Matt ASP .Net 14 01-30-2004 09:15 AM
conflict between validation controls and "confirm" Bob D ASP .Net Web Controls 1 01-15-2004 05:01 PM



Advertisments