Click here to Skip to main content
13,006,360 members (68,997 online)
Rate this:
Please Sign up or sign in to vote.

I want a Gridview which contains a textbox to edit and with a Validate control which will validate the text box value. But when I put the two controls under <itemtemplate> tag I can see the textbox but if I put the same under <edititemtemplate> tag I can't see the textbox.

Here is my code...

<asp:TemplateField HeaderText="Sort Order" SortExpression="Sort_Order" meta:resourcekey="APPROVAL_STATUSResource">
     <itemstyle width="10%" horizontalalign="right"></itemstyle>
     <headerstyle width="10%" horizontalalign="right" ></headerstyle>
     <asp:TextBox runat="server" Text='<%#Bind("Sort_Order") %>' ID="txtSortOrder" ></asp:TextBox>
     <asp:CompareValidator ControlToValidate="txtSortOrder" Operator="GreaterThanEqual" Type="Integer" ValueToCompare="0" ErrorMessage="The Sort Order Field cannot be negative." Display="None" runat="server" />
Posted 2-Feb-13 9:54am
Updated 2-Feb-13 19:06pm
Joezer BH38.9K
Edo Tzumer 3-Feb-13 1:08am
In this code you SEE or DON'T SEE the textbox?

1 solution

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

Solution 1

Hi Check this ?

<asp:TemplateField HeaderText="StudentName"  SortExpression="StudentName">
 <asp:TextBox ID="txtStudentName" runat="server" Width="85px" Text='<%#Eval("StudentName") %>'/>
 <asp:Label ID="lblStudentName" runat="server" Text='<%#Eval("StudentName") %>'/>
 <asp:TextBox ID="txtFTRStudentName" runat="server" Width="85px"/>
 <asp:RequiredFieldValidator ID="rfvStudentName" runat="server" ControlToValidate="txtFTRStudentName" Text="*" ValidationGroup="validation"/>

Sure , this will help you.

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.170628.1 | Last Updated 3 Feb 2013
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