Solved

Problem finding control in EditItemTemplate of FormView

Posted on 2007-11-13
3
1,542 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
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)
0
 
LVL 16

Expert Comment

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

0
 
LVL 1

Author Closing Comment

by:nkewney
ID: 31409123
Thanks for this.

NIck
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

16 Experts available now in Live!

Get 1:1 Help Now