Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi,
 
How can i validate TextBox in nestedGridView.
I want to Validate the Child Grid, when i insert the records into child grid then i need to validate, if data is inserted in TextBox or not. if data is inserted then only data is added in grid.
 

can any one help me for this issue....
Posted 3-Oct-12 21:07pm
Edited 3-Oct-12 23:46pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

then what is problem ,use validation group property for footer control .
  Permalink  
Comments
solanki.net at 4-Oct-12 3:21am
   
because validation group is same for all .set different validation group name for child grid textbox and linkbutton .means it should same for these both control but it should not match with any other validation group name (mean unique)
solanki.net at 4-Oct-12 4:43am
   
suppose your child grid has textbox and link button 'Add' in footer .then u should do like that :
 

<asp:TextBox ID="txtName" runat="server" ValidationGroup="ChildFooter" >
<asp:RequiredFieldValidator ID="rfvName" runat="server" ValidationGroup="ChildFooter" ErrorMessage="Enter Name" ControlToValidate="txtName" >

 

 
<asp:LinkButton ID="btnAdd" runat="server" CommandArgument='<%#Container.DataItemIndex %>' CommandName="AddChild" Text="Add" ValidationGroup="ChildFooter">
solanki.net at 4-Oct-12 5:48am
   
send me your code
solanki.net at 4-Oct-12 6:09am
   
have u given same validation group name for any other control ? if not send code of your both grids
solanki.net at 4-Oct-12 6:26am
   
change your attitude next time when u asking help dont give response like that .i am not interested in your code u only asked for help then only i asked your code.
solanki.net at 4-Oct-12 6:31am
   
sorry i thought u directly saying no for your code .
solanki.net at 4-Oct-12 6:42am
   
k,then u should set validation group for your all controls .
solanki.net at 4-Oct-12 7:00am
   
then its difficult to solve your problem without checking your code.
solanki.net at 4-Oct-12 7:12am
   
your welcome.
Member 9504998 at 15-Nov-12 4:07am
   
Hello solanki.net,
I have a problem on NestedGridView Validator. I did exactly as you said inside childgrid. I have a textbox, a validator control and a summary like that:
'''''' textbox to validate

<asp:TextBox ID="txtNCont" runat="server" ValidationGroup="ChildFooter"/>
<asp:RequiredFieldValidator ID="RFVInsNome" runat="server" ValidationGroup="ValGruppoChildFooter" ControlToValidate="txtNCont" ErrorMessage="inserimento: nome obbligatorio" Text="*" />

 
'''' Insert button

<asp:Button ID="btnInsert" runat="server" Text="Inserimento" ToolTip="Salva inserimento contatto" CommandName="Add" Height="20px" ValidationGroup="ValGruppoChildFooter" />

 
'''ValidationSummary
<asp:ValidationSummary ID="ValidationSummary" runat="server"
ShowMessageBox="True" ShowSummary="False"
ValidationGroup="ValGruppoChildFooter" />
 
I get a message box but the message is repeated twice inside the msgbox:
- inserimento: nome obbligatorio
- inserimento: nome obbligatorio
 
The same procedure I used on a normal textbox (outside of a grid) and it works. As a javascript control, it doesn't "submit" a page, I think. Could you help me to find the error, please?
 
Thanks in advance
Member 9504998 at 15-Nov-12 4:29am
   
Sorry, I found this about fire the event twice:
===============================================================================
It's because you handled the RowCommand event twice: one is defined in your
ASPX: OnRowCommand="GridView1_RowCommand"; another is defined by your
code-behind: Protected Sub GridView1_RowCommand(ByVal sender As Object,
ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles
GridView1.RowCommand
 
You need to remove one.
===============================================================================
 
I removed but nothing changed.
 
Thanks again
Member 9504998 at 15-Nov-12 5:02am
   
Hello, I think I got the question.
If in the Parent grid there are 2 records, there will be one footer for each parent, so the message appears twice.
If I have 3 parents records, there will be 3 footers, one for each parent. So the messages will repeat three times.
… and so on.
So the messages are associated to each footer in the parent record.
 
How to validate only the footer I’m inserting data?
 
Thanks
 
Elaine
Member 9504998 at 19-Nov-12 4:50am
   
sorry, where are the codeproject experts to answer me this question?
thanks
Elaine

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



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100