Problem finding control in EditItemTemplate of FormView

Posted on 2007-11-13
Medium Priority
Last Modified: 2013-11-07
Dear Experts,

I'm having some trouble finding a control within the EditItemTemplate of a formview.

I have listed my code below and how I'm trying to find the control.

Any help would be greatly appreciated.


My FormView...



    <legend><asp:Image ImageUrl="~/img/pt.gif" ID="Image3" runat="server" /> Select Account(s)</legend><asp:Label ID="Label1" Font-size="Large" Font-Bold="true" runat="server" Text=""></asp:Label>

   <asp:Panel ID="Panel2" runat="server" CssClass="modalPopup" Style="display: none" Width="233px">

   <br />

   <asp:Panel ID="Panel99" runat="server" CssClass="Modal" Style="display: none" Width="233px">


To add a control to found panel...

  Dim Panel1x As Panel = FormView1.FindControl("Panel99")
  Dim Label33 As New Label
  Label33.Text = " "
  Label33.Font.Bold = True

Object reference...
Question by:nkewney
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 22

Accepted Solution

RedKelvin earned 2000 total points
ID: 20276300
Try using

Dim Panel1x As Panel = CType(FormView1.FindControl("Panel99"), Panel)

or from within a grid event such as "DeleteCommand"

Dim Panel1x As Panel = CType(e.Item.FindControl("Panel99"), Panel)
LVL 16

Expert Comment

ID: 20276478
Where are you calling the code?  The problem could be that the formview isn't actually in the right mode at the time you call the code.  Thus it cannot find the panel because it does not yet exist.

Double check that:   FormView1.CurrentMode = FormViewMode.Edit:  

If not, you may need to call:  FormView1.ChangeMode(FormViewMode.Edit)


Author Closing Comment

ID: 31409123
Thanks for this.


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question