Click here to Skip to main content
11,932,402 members (57,303 online)
Rate this:
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
Joezer BH38.4K
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") %>'/>

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
Web04 | 2.8.151126.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