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 Dnyaneshwar@Pune 604
1 thatraja 370
2 OriginalGriff 319
3 Sergey Alexandrovich Kryukov 243
4 Gihan Liyanage 194
0 OriginalGriff 737
1 Dnyaneshwar@Pune 604
2 Kornfeld Eliyahu Peter 505
3 Sergey Alexandrovich Kryukov 372
4 thatraja 370


Advertise | Privacy | Mobile
Web04 | 2.8.140902.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