473,791 Members | 3,071 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FindControl help...please

I have a web page that I'm trying to toggle between current data and
archived data. So far so good. To preserver the integrity of the
archived data, I need to disable the Edit, Delete, and New links in
the Form View. The below code is what I've been trying to use, and
I've tried it in various events with no luck. I need some help.

Control btn1 = this.fvCapture. FindControl("Ed itButton");
Control btn2 = fvCapture.FindC ontrol("NewButt on");
Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
Button b1 = btn1 as Button;
Button b2 = btn2 as Button;
Button b3 = btn3 as Button;
if (b1 != null)
{
b1.Enabled = false;
}
if (b2 != null)
{
b2.Enabled = false;
}
if (b3 != null)
{
b3.Enabled = false;
}

Thankyou

Nov 8 '07 #1
4 2224
Liz

"Dave" <Da**********@J acobs.comwrote in message
news:11******** **************@ i38g2000prf.goo glegroups.com.. .
>I have a web page that I'm trying to toggle between current data and
archived data. So far so good. To preserver the integrity of the
archived data, I need to disable the Edit, Delete, and New links in
the Form View. The below code is what I've been trying to use, and
I've tried it in various events with no luck. I need some help.
Hard to figure your context ... but this worked fine for me:

Button b = (Button)FormVie w1.FindControl( "editButton ");

b.Enabled = false;

I just handled a button on dropped on the FormView to look at this ... don't
know what event you're trying to handle but not sure why it should matter ..

>
Control btn1 = this.fvCapture. FindControl("Ed itButton");
Control btn2 = fvCapture.FindC ontrol("NewButt on");
Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
Button b1 = btn1 as Button;
Button b2 = btn2 as Button;
Button b3 = btn3 as Button;
if (b1 != null)
{
b1.Enabled = false;
}
if (b2 != null)
{
b2.Enabled = false;
}
if (b3 != null)
{
b3.Enabled = false;
}

Thankyou

Nov 9 '07 #2
Liz

"Dave" <Da**********@J acobs.comwrote in message
news:11******** **************@ i38g2000prf.goo glegroups.com.. .
>I have a web page that I'm trying to toggle between current data and
archived data. So far so good. To preserver the integrity of the
archived data, I need to disable the Edit, Delete, and New links in
the Form View. The below code is what I've been trying to use, and
I've tried it in various events with no luck. I need some help.

Control btn1 = this.fvCapture. FindControl("Ed itButton");
Control btn2 = fvCapture.FindC ontrol("NewButt on");
Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
Button b1 = btn1 as Button;
Button b2 = btn2 as Button;
Button b3 = btn3 as Button;
if (b1 != null)
{
b1.Enabled = false;
}
if (b2 != null)
{
b2.Enabled = false;
}
if (b3 != null)
{
b3.Enabled = false;
}
btw, I also tried your construct:

Control b2 = FormView1.FindC ontrol("newButt on");

Button b22 = b2 as Button;

b22.Enabled = false;

and it worked too .... apparently, your FindControl call is not finding;
must be in the wrong level of the containment hierarchy ... if you cannot
get this going you could just try to handle the database events and cancel
them before they occur if the program state is "archive" ... not as elegant
of course .. but workable if you're in a bind


Nov 9 '07 #3
Liz,
Thanks for your help and Comments. Where would you suggest that I put
it in the containment hierarchy?

Dave
On Nov 9, 12:42 am, "Liz" <l...@tiredofsp am.comwrote:
"Dave" <Dave.Burk...@J acobs.comwrote in message

news:11******** **************@ i38g2000prf.goo glegroups.com.. .


I have a web page that I'm trying to toggle between current data and
archived data. So far so good. To preserver the integrity of the
archived data, I need to disable the Edit, Delete, and New links in
the Form View. The below code is what I've been trying to use, and
I've tried it in various events with no luck. I need some help.
Control btn1 = this.fvCapture. FindControl("Ed itButton");
Control btn2 = fvCapture.FindC ontrol("NewButt on");
Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
Button b1 = btn1 as Button;
Button b2 = btn2 as Button;
Button b3 = btn3 as Button;
if (b1 != null)
{
b1.Enabled = false;
}
if (b2 != null)
{
b2.Enabled = false;
}
if (b3 != null)
{
b3.Enabled = false;
}

btw, I also tried your construct:

Control b2 = FormView1.FindC ontrol("newButt on");

Button b22 = b2 as Button;

b22.Enabled = false;

and it worked too .... apparently, your FindControl call is not finding;
must be in the wrong level of the containment hierarchy ... if you cannot
get this going you could just try to handle the database events and cancel
them before they occur if the program state is "archive" ... not as elegant
of course .. but workable if you're in a bind- Hide quoted text -

- Show quoted text -

Nov 9 '07 #4
Liz

"Dave" <Da**********@J acobs.comwrote in message
news:11******** **************@ t8g2000prg.goog legroups.com...
Liz,
Thanks for your help and Comments. Where would you suggest that I put
it in the containment hierarchy?
where it belongs? lol ... sorry; I'm not all that clear on this issue and
only have a snippet of your code, and I'd like to get clear on it;
meanwhile, have a look at these links which appear to be a good start on
sorting it out:

http://msdn2.microsoft.com/en-us/lib...ss(vs.80).aspx
http://msdn2.microsoft.com/en-us/lib...0b(VS.80).aspx
http://msdn2.microsoft.com/en-us/lib...fb(VS.80).aspx

apparently fvCapture is not adequate as an unambiguous naming container in
your code .. you might turn on Trace and look at the Control tree too ..

maybe someone else has a firm grasp on this ... I think part of the problem
is that controls which use templates can generate multiple instances of a
child controls that have to be resolved through reference to the particular
naming container in which they reside .. and that seems to be the case even
where, for example, your button only exists in one of the templates and does
not repeat (or maybe not ... because I *can* get a reference to the button
in my FormView)

anyway, the MSDN articles should be a start ... let us know when this is
fully resolved !

L

On Nov 9, 12:42 am, "Liz" <l...@tiredofsp am.comwrote:
>"Dave" <Dave.Burk...@J acobs.comwrote in message

news:11******* *************** @i38g2000prf.go oglegroups.com. ..


>I have a web page that I'm trying to toggle between current data and
archived data. So far so good. To preserver the integrity of the
archived data, I need to disable the Edit, Delete, and New links in
the Form View. The below code is what I've been trying to use, and
I've tried it in various events with no luck. I need some help.
Control btn1 = this.fvCapture. FindControl("Ed itButton");
Control btn2 = fvCapture.FindC ontrol("NewButt on");
Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
Button b1 = btn1 as Button;
Button b2 = btn2 as Button;
Button b3 = btn3 as Button;
if (b1 != null)
{
b1.Enabled = false;
}
if (b2 != null)
{
b2.Enabled = false;
}
if (b3 != null)
{
b3.Enabled = false;
}

btw, I also tried your construct:

Control b2 = FormView1.FindC ontrol("newButt on");

Button b22 = b2 as Button;

b22.Enabled = false;

and it worked too .... apparently, your FindControl call is not finding;
must be in the wrong level of the containment hierarchy ... if you cannot
get this going you could just try to handle the database events and
cancel
them before they occur if the program state is "archive" ... not as
elegant
of course .. but workable if you're in a bind- Hide quoted text -

- Show quoted text -


Nov 9 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1723
by: Mike Speak | last post by:
On my page_load, I am populating a Datagrid through the normal manner (which works) before attempting to pick out the items in one column to use in another part of my page. This is all within page_load. Within my Datagrid I have an <ItemTemplate/> tag with a child <asp:Label/> tag. The ID on the <asp:Label/> tag is set to "lblDescription". I am using the following code to iterate over the DataGrid control and pick out the descriptions...
4
4158
by: MattB | last post by:
This is just a rephrased version of a question I posted earlier. I think I'm closer now, so it seemed worthy of a new (more specific) post. In my repeater I'm dynamically creating text boxes, so at compile time I don't know what text boxes are going to be present at run time. This is where it seems the FindControl method would be come into play. I loop through a list of control (all textboxes) names I created on page load and see if they...
5
23302
by: sck10 | last post by:
Hello, I am using the code below to set the values of a DetailsView template field using FindControl. My question is how would you find a control if its a Boundfield control? For example, how would I reference the following BoundField ("NTAccount") in the Sub dvDetail_PreRender sub? Any help would be appreciated... <asp:BoundField DataField="NTAccount" HeaderText="NT Account" />
2
6566
by: christof | last post by:
How to do it: My page: <asp:DataList ID="dataListRoleMembers" ...> .... <FooterTemplate> <asp:LinkButton ID="btnAddMember" runat="server" OnClick="btnAddMember_Click">Add...</asp:LinkButton> <asp:TextBox ID="txtAddMember" runat="server"></asp:TextBox>
2
7537
by: Bruno Alexandre | last post by:
Hi guys, I have this code: Dim gv As GridViewRow Dim str As String = "" Dim dd As DropDownList For Each gv In gvItems.Rows If gv.RowType = DataControlRowType.DataRow Then
2
8296
by: encoad | last post by:
Hi everyone, I'm slowly going mad with Masterpages and the FindControl. After a couple days of figuring out how to use the FindControl command from within a Masterpage, I still can't explain why this code does not function. As you can see if you compile it with 2005, clicking "Button" will achieve the desired result of displaying the contents of the textbox, however the test(); function called from Page_Load does not do anything. ...
11
1898
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
I am trying to get the text of an item in a GridView, but am doing something wrong. Can someone help me with the correct C# statement I need? Below is my GridView and my attempt to get the control. Thank you. string option = ((TextBox)dgDropDownMenus.Items.FindControl("txtName")).Text; -----------------------DataGrid------------------------------------------- <asp:datagrid id="dgMenus" style="Z-INDEX: 101; LEFT: 0px; POSITION:
1
1330
by: divingIn | last post by:
Hi, I have a master page and a content page. From my content page i can access the master page controls using Master.FindControl() but i cannot access controls from my content page using FindControl(). For any control it just returns null. I have been trying for so long with no success. so frustrated! Please help. eg. FindControl("Table_Search") and FindControl("Content1") returns null. <CODE> <%@ Page Language="C#"...
7
5701
by: AAaron123 | last post by:
Me.FindControl("MissionScheduleID"), below returns null. Do you know what I'm doing wrong? Thanks ***In my .aspx file I have: asp:Content ID="Content3" contentplaceholderid="MainMasterLeftDataID" runat="server">
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9995
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.