Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 <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...

XML
<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
Updated 2-Feb-13 19:06pm
v4
Comments
Joezer BH 3-Feb-13 1:08am    
In this code you SEE or DON'T SEE the textbox?

1 solution

Hi Check this ?

XML
<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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900