Click here to Skip to main content
16,017,297 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,
I am trying to insert a text inside a header template like the below code:---
XML
<asp:TemplateField HeaderText="PlanningId" ItemStyle-CssClass="TACenter">
        <HeaderTemplate>
         Planning Id<br />
            <asp:TextBox ID="txt_planningid" runat="server"></asp:TextBox>
        </HeaderTemplate>
        </asp:TemplateField>



But While doing the above code i am getting the following error:-

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.LinkButton'.


Please give me solution as early as possible,its urgent.

Thank you
Posted
Comments
Nandakishore G N 5-Mar-13 2:23am    
the error is showing the reason..i.e, literal control to linkbutton.probably in your rowdatabound or any grid related events of codebehind you have written (Literal) instead of (LinkButton)..check it..

I have used sorting in gridview.It was using some sortdirection variable of System.Web.UI.WebControls .And when i removed sorting from my page,there was no exception.
 
Share this answer
 
 
Share this answer
 
In header, you cannot use controls.
If your Heading will be dynamic; then use Label On the top of your Page.
 
Share this answer
 
v2
Comments
Member 8624186 4-Mar-13 23:07pm    
We can add controls in header,the above code is working perfectly fine in another page,but i m not getting what is the problem in this page and what do you mean by this exception?

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