473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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("EditButton");
Control btn2 = fvCapture.FindControl("NewButton");
Control btn3 = fvCapture.FindControl("DeleteButton");
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 2196
Liz

"Dave" <Da**********@Jacobs.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.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)FormView1.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("EditButton");
Control btn2 = fvCapture.FindControl("NewButton");
Control btn3 = fvCapture.FindControl("DeleteButton");
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**********@Jacobs.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.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("EditButton");
Control btn2 = fvCapture.FindControl("NewButton");
Control btn3 = fvCapture.FindControl("DeleteButton");
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.FindControl("newButton");

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...@tiredofspam.comwrote:
"Dave" <Dave.Burk...@Jacobs.comwrote in message

news:11**********************@i38g2000prf.googlegr oups.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("EditButton");
Control btn2 = fvCapture.FindControl("NewButton");
Control btn3 = fvCapture.FindControl("DeleteButton");
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.FindControl("newButton");

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**********@Jacobs.comwrote in message
news:11**********************@t8g2000prg.googlegro ups.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...@tiredofspam.comwrote:
>"Dave" <Dave.Burk...@Jacobs.comwrote in message

news:11**********************@i38g2000prf.googleg roups.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("EditButton");
Control btn2 = fvCapture.FindControl("NewButton");
Control btn3 = fvCapture.FindControl("DeleteButton");
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.FindControl("newButton");

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
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...
4
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...
5
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,...
2
by: christof | last post by:
How to do it: My page: <asp:DataList ID="dataListRoleMembers" ...> .... <FooterTemplate> <asp:LinkButton ID="btnAddMember" runat="server"...
2
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
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...
11
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....
1
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...
7
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"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.