Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 13th, 2006, 11:42 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding a Panel control in FormView

I'm trying to add a panel to an EditItemTemplate of a FromView without success. I have a checkbox with the checked property bound to a field in the FormView. I'm trying to react to the checkbox's checked state by making a panel visible if the checkbox is checked and invisible if it is not checked. Anyone with any suggestions? I'm not finding much in the way of documentation for this problem. Thanks. Greg.

Reply With Quote
  #2 (permalink)  
Old August 6th, 2010, 03:52 AM
Registered User
 
Join Date: Aug 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Having same problems in FormView on InsertItem Template.
Any ideas will be welcome.
Imar suggested Googling FINDCONTROL. I took onelook, but it was almost overwhelming.
Let me know what you find!
Reply With Quote
  #3 (permalink)  
Old August 13th, 2010, 06:06 AM
Authorized User
 
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default solution

Hi Steve,

: public void CheckedBox1l_CheckedChanged(object sender, EventArgs e)
{
CheckBox Mychk = (CheckBox)sender;
Panel MyPanel = (Panel)FormView1.FindControl("Panel2");
MyPanel.Visible = Mychk.Checked;
}

try this;
Reply With Quote
  #4 (permalink)  
Old August 13th, 2010, 08:20 AM
Registered User
 
Join Date: Aug 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. Is this in VB or C? Could you post the VB version, please.
Oguchi
Reply With Quote
  #5 (permalink)  
Old August 14th, 2010, 02:38 AM
Authorized User
 
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Oguchi,
Thanks for getting back to me.Actully this code is for c#. Becuse we are working on c# only.


Let me know if you have any more query.

Thanks
Reply With Quote
  #6 (permalink)  
Old August 18th, 2010, 12:32 AM
Friend of Wrox
Points: 1,749, Level: 16
Points: 1,749, Level: 16 Points: 1,749, Level: 16 Points: 1,749, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2007
Location: San Diego, CA, USA.
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

Quote:
Originally Posted by daccit View Post
Hi Steve,

: public void CheckedBox1l_CheckedChanged(object sender, EventArgs e)
{
CheckBox Mychk = (CheckBox)sender;
Panel MyPanel = (Panel)FormView1.FindControl("Panel2");
MyPanel.Visible = Mychk.Checked;
}

try this;
It's easier to convert code in a language you're not comfortable with into your own language because that way the final product at least makes sense because you know the syntax. Therefore, I'd recommend that you translate it into VB yourself, since daccit and I are primarily C# guys. You don't want to see how many compilers our VB suggestions would throw. :) You are simply creating an event handler for a particular checkbox, CheckedBox1, when it's state is changed (it's checked or unchecked). Here's what's going on in this example, this is the code you're trying to recreate in VB.

First you create a new checkbox control in code, Mychk, and load the checkbox which has changed (the sender) into it. This is why you are casting the sender, so that it is the correct type when you store it in Mychk. You then repeat this process with the panel. You create a new panel in code, MyPanel. Using the FindControl() method you retrieve the panel with id="Panel2" that's inside FormView1, not that again you have to cast it to the correct type (Panel) in order to assign it to MyPanel (just like you had to for Mychk).

The third step is actually two steps combined. You are setting the visible property of MyPanel to true (which makes it visible) or false. However, you don't see any booleans, because the code directly assigns the Checked value (which is either true or false) from the Mychk checkbox. So if someone checks the checkbox, it's state changes and this function fires. The value of the checkbox is now checked and so this statement is true; line three assigns this "true" value to the visible property of the panel and the panel therefore appears. Now if someone unchecks the box, it's status changes and this function fires again. Now it's not checked so the Checked value is "false" and when that's assigned to MyPanel.Visible, the panel disappears. I hope that's clear?
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch. 4 - Adding FormView control problem donesquire BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 2 August 6th, 2010 03:56 AM
Control panel maz_alaameri ASP.NET 2.0 Professional 0 March 17th, 2008 06:59 AM
FormView Control lokraj ASP.NET 2.0 Basics 0 September 11th, 2007 08:51 AM
Making a Panel visible in a FormView steve35719 VB How-To 0 June 29th, 2006 07:49 AM
ViewState problem when adding a panel to a panel koekie17 C# 3 February 20th, 2006 09:17 AM



All times are GMT -4. The time now is 09:11 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.