Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#3.0 C# ASP.NET Gridview
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>
     <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 10:54am
Edited 2-Feb-13 20:06pm
Edo Tzumer at 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
0 Peter Leow 315
1 Mika Wendelius 275
2 TheRealSteveJudge 194
3 CHill60 190
4 Abhinav S 155
0 Sergey Alexandrovich Kryukov 8,613
1 OriginalGriff 6,546
2 Peter Leow 3,897
3 Zoltán Zörgő 3,456
4 Richard MacCutchan 2,472

Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2015
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