Solved

Problem finding control in EditItemTemplate of FormView

Posted on 2007-11-13
3
1,541 Views
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.

Thanks
Nick

My FormView...

<EditItemTemplate>

<fieldset>

    <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">

   
   </asp:Panel>
     
   <br />
   

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

==THIS IS THE PANEL==
       
   </asp:Panel>

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
  Panel1x.Controls.Add(Label33)

Object reference...
0
Comment
Question by:nkewney
3 Comments
 
LVL 22

Accepted Solution

by:
RedKelvin earned 500 total points
Comment Utility
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)
0
 
LVL 16

Expert Comment

by:GreymanMSC
Comment Utility
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)

0
 
LVL 1

Author Closing Comment

by:nkewney
Comment Utility
Thanks for this.

NIck
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now