Click here to Skip to main content
13,046,176 members (67,342 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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
Updated 3-Oct-12 23:46pm

1 solution

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

Solution 1

then what is problem ,use validation group property for footer control .
pranathis012 4-Oct-12 3:15am
no when i use the require field validator and validation group property , it's not working properly.
for ex in my parent grid i have 4 rows and child grid i want to validate the textbox means in my parent grid 4 rows also it's validating but i want to validate only selected row selected child grid textbox only. 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)
pranathis012 4-Oct-12 4:13am
i want to check validation for child grid, here i'm passing validation group that should be unique for every row how to pass the unique value. 4-Oct-12 4:43am
suppose your child grid has textbox and link button 'Add' in footer .then u should do like that :

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

<FooterTemplate >

<asp:LinkButton ID="btnAdd" runat="server" CommandArgument='<%#Container.DataItemIndex %>' CommandName="AddChild" Text="Add" ValidationGroup="ChildFooter">
pranathis012 4-Oct-12 5:45am
i'm also do the same thing 4-Oct-12 5:48am
send me your code
pranathis012 4-Oct-12 6:04am
<asp:TextBox ID="txtMaterialQty" runat="server" width="90%" onKeyUp="ValidateText(this)" ValidationGroup="Project">
<asp:RequiredFieldValidator ID="Req1" runat="server" ControlToValidate="txtMaterialQty" ErrorMessage="*" ValidationGroup="Project"/>

<asp:LinkButton ID="lnkAdd" Text="Add" CommandName="Add" ValidationGroup="Project"
runat="server" /> 4-Oct-12 6:09am
have u given same validation group name for any other control ? if not send code of your both grids
pranathis012 4-Oct-12 6:15am
no.. 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.
pranathis012 4-Oct-12 6:30am
u ask me the question..
have u given same validation group name for any other control ?
i answer for that i'm not given same validation group name to other control's like in parent grid controls as well as child grid also 4-Oct-12 6:31am
sorry i thought u directly saying no for your code .
pranathis012 4-Oct-12 6:34am
no if i send source code means it's take more space that's want only ,i'm not sending total code 4-Oct-12 6:42am
k,then u should set validation group for your all controls .
pranathis012 4-Oct-12 6:56am
no i'm facing the same problem 4-Oct-12 7:00am
then its difficult to solve your problem without checking your code.
pranathis012 4-Oct-12 7:08am
k thank u 4-Oct-12 7:12am
your welcome.
Member 9504998 15-Nov-12 4:07am
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" />

<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 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

You need to remove one.

I removed but nothing changed.

Thanks again
Member 9504998 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?


Member 9504998 19-Nov-12 4:50am
sorry, where are the codeproject experts to answer me this question?

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2017
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