Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 C# ASP.NET Gridview
Hi,
 
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 tag I can see the textbox but if I put the same under 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>
     <EditItemTemplate>
     <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" />
     </EditItemTemplate>
</asp:TemplateField>
Posted 2-Feb-13 9:54am
Edited 2-Feb-13 19:06pm
v4
Comments
Edo Tzumer at 3-Feb-13 1:08am
   
In this code you SEE or DON'T SEE the textbox?

1 solution

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

Solution 1

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

Sure , this will help you.
  Permalink  

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

  Print Answers RSS
0 Maciej Los 250
1 OriginalGriff 210
2 Manfred R. Bihy 190
3 CHill60 180
4 _Amy 155
0 OriginalGriff 7,445
1 Sergey Alexandrovich Kryukov 6,177
2 Maciej Los 3,774
3 Peter Leow 3,478
4 CHill60 2,702


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 3 Feb 2013
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