Find control - Form > FormView > DataList not working

Ok so i have a label control called lblDeadline

I use this to get to most controls

fvTicketDetails.findControl("controlname")

However, when i try to get to the control lblDeadline it cant seem to find it. I have tried 

dlDeadline.FindControl("controlname") which is the datalist but obviously it doesn't see the Datalist because its within my formview editItem template.

Please can anyone tell me how to retrieve lblDeadline from fvTicketDetails EditItemTemplate which has a datalist and a control inside ItemTemplate of that datalist.

 I hope that makes some sense.

Thanks

Matt
 

0
intrigue
4/23/2007 5:48:03 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

6 Replies
433 Views

Similar Articles

[PageSpeed] 35

Well, you certainly need to get the datalist before you can get at a control inside of the datalist... So you have to first ensure you are in edit mode... you can do this during a modechanged event.

    protected void FormView1_ModeChanged(object sender, EventArgs e)
    {
        if (((FormView)sender).CurrentMode == FormViewMode.Edit)
        {
            DataList dl = (DataList)((FormView)sender).FindControl("DataList1");
            // get your selected index or whatever you want...
            int MySelectedItem = dl.SelectedIndex;
            // you can even get at controls inside the datalist now...
            Label lbl = (Label)dl.FindControl("lblMyLabel");

        }
    }
 i hope this helps
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." ~ Douglas Adams

http://pixelsyndicate.com/ps/
0
pixelsyndicate
4/23/2007 6:03:29 PM

Aplogies but i use VB i should have mentioned that, however that does indeed help and i will try and convert it and see if i can get it working

Funnily enough i just tried;

        Dim dlDeadline As DataList = fvTicketDetails.FindControl("dlDeadline")
        Dim lblDeadline As Label = dlDeadline.FindControl("lblDateDeadline")
But no such look  i will keep trying :)

Thanks

Matt
 

0
intrigue
4/23/2007 6:08:20 PM
intrigue:

Aplogies but i use VB i should have mentioned that, however that does indeed help and i will try and convert it and see if i can get it working

Funnily enough i just tried;

        Dim dlDeadline As DataList = fvTicketDetails.FindControl("dlDeadline")
        Dim lblDeadline As Label = dlDeadline.FindControl("lblDateDeadline")
But no such look  i will keep trying :)

Thanks

Matt
 

 

Try casting ...

Dim dlDeadline As DataList = CType(fvTicketDetails.FindControl("dlDeadline"), FormView)
Dim lblDeadline As Label = CType(dlDeadline.FindControl("lblDateDeadline"), Label)


"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." ~ Douglas Adams

http://pixelsyndicate.com/ps/
0
pixelsyndicate
4/23/2007 6:12:58 PM

ARGH!!!! I have tried this and lots of others and still cant get it working.

What  about multiView is that the way to go?

Matt 

0
intrigue
4/23/2007 6:33:24 PM

Multiview can be just as bad... it will have objects containing objects, containing objects... the same thing you are dealing with now. When you debug, are these control references you making (Dim dlDataList as DataList = CType(fv.findcontrol("mydatalist")) coming up with nulls (or in the case of VB.NET, "nothing"s?)

I go as far as to use DropDownLists in my formviews, but haven't put datalists in formviews!

Here is an article I wrote on binding selectable, dynamically populated, dropdownlists to FormViews (or GridView)

http://forums.asp.net/thread/1631435.aspx

Should be a huge help to you (but its in c#)

Just remember... These two lines are equal...

Dim dlDataList as DataList = CType(fv.findcontrol("mydatalist"))
DataList dlDataList = (DataList)fv.FindControl("mydatalist");


"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." ~ Douglas Adams

http://pixelsyndicate.com/ps/
0
pixelsyndicate
4/23/2007 7:37:22 PM

sorry... the two lines that are the same should be...

 

Dim dlDataList as DataList = CType(fv.findcontrol("mydatalist"), DataList)
DataList dlDataList = (DataList)fv.FindControl("mydatalist");


"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." ~ Douglas Adams

http://pixelsyndicate.com/ps/
0
pixelsyndicate
4/23/2007 7:39:27 PM
Reply:

Similar Artilces:

SOS. >>>>>>>>HELP ME????????>>Web Matrix do not work in Win XP pro
Hi everbody!!!! I have a problem with webmatrix. My problem is?? i install ASP.NET Web Matrix but it is not work. My system is XP pro. I alredy install NET Framework 1.1. The program do not show nothing. But when i open i see picture which there webmatrix after some this disappeared and after i wait but this not work. When i use win 2000 this work excellent. But now problem . I test this in two PC. But no result. I want also add that i install XP sp 2. But Proqram do not work... Thanks!!!! Hi, Can you take a look at these threads: view post 258398 and view post 252245 Regar...

Can't get the Web Controls to work.. The Build.Bat file doesn't work? HELP>> ARGGG>.
Hi.. I was wanting to use the IE Web Controls, the Tab Strip, etc, and play with it.. Since I have IIS 5, I thought I'd copy them there using the Read me.txt instructions and then copy to a dev server that I use at a web host.. Well, everything worked except the Build file doesn't build the Microsoft.UI.Webcontrols.DLL file? When I try to run it by double clicking on it, it runs really fast in  the DOS window, but I can't see what it says and it closes.. So I tried to do so manually and I received an error that the "cse.exe is not recognized as an internal or external command or batch...

WinXP->NET works but not Win98->WinXP->Net
Hi, I have a WinXP pro machine that connects to the net just fine, (I am using it for this post). I also have a win 98 machine on the network and it can see my WinXP machine, (ping by IP and by name). But I cannot get the win 98 machine on the net. I have disabled my Firewalls, (ZoneAlarm and Windows). But I cannot get anything. What setting could I be missing? How can I connect my machine to the net thru my Win XP box. Many thanks. Simon -- http://urlkick.com/ Free URL redirection service. Turns a long URL into a much shorter one. On Sat, 24 Mar 2007 in ...

ERROR >>>>>>>>>>>master page
can any budy give me an answer of given question this question is ask in interview we have an usercontrol in .net 1.0,1.1 why microsoft implimented the masterpage concept in 2.0 as work done by master page is same as usercontrol do   can any budy gives mw an ans -----------why we use master pages........???????? Friend, this article explains you why do we use the master pages http://dotnetperls.com/Content/Master-Page-Code-Behind.aspx and this one http://www.careerride.com/ASP.NET-Master-Pages-Questions.aspx Good luck!Please Don't forget to click "Mark as Answer&quo...

Web Control with <abc:Control>TEXT HERE</abc:Control>
I'm trying to create a custom web control and support putting stuff in the middle - between the openning and closing tags:  <abc:Control>TEXT HERE</abc:Control> I would like to be able to put both text and other web controls between the tags. How do I do this? hi, why not the normal web user control? It also works fine. Maybe it is hard to create a control with the openning and closing tags...

HELP>>HELP>>>
The server abended due to a room that was too hot, it corrupted GroupWise so now when it reboots it hangs. How do I restart the server and get it not to load the autoexec.ncf which contains GW? Your immediate assistance would be greatly appreciated! Thanks. Barbara barbara.roy@po.state.ct.us wrote: > The server abended due to a room that was too hot, it corrupted GroupWise > so now when it reboots it hangs. How do I restart the server and get it > not to load the autoexec.ncf which contains GW? Your immediate assistance > would be greatly appreciated! Thanks. B...

applying signatures>>>>>
Name: Greg Donsberger Email: donsbergeratecnodotcom Product: Thunderbird Summary: applying signatures>>>>> Comments: Thunderbird!!! I'd like to be able to apply a signature to my e-mails......but not every one with a particular account. outlook express has an "insert option" for signatures....you still have to set it up.....but you insert it yourself, instead of it being a default setting for the account. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729) From ...

System.NET >> Authentication Manager >>PreAuthenticate
I want to authenticate to a URL, which uses Windows Authentication Dialog box ..... I am not too sure how to go .... I am using Preauthenticate method of the Authentication Manager class. Its GIVES ME AN ERROR message saying "System.NullReferenceException: Object reference not set to an instance of an object " the CODE IS : AuthenticationManager.PreAuthenticate(objRequest, objNetCred ); I have already set the Credentials with username and password in the objNetCred(NetworkCredential Object ) the url in the objRequest [ WebRequest.Create(url) ] . ...

Fox 3 Beta 5 >>>>>>>
Name: Hank Hill Product: Firefox Summary: Fox 3 Beta 5 >>>>>>> Comments: Wooosh! Love what it does. Faster than anything. I look forward to more. Thank you. From URL: http://hendrix.mozilla.org/ ...

simple code for search please>>>>>>>
hi>>i am work in project with asp.neti have code that search words in  only one page ,but i want simple code for search words in multiple pagesi mean i want put search box in home page and i can search for words in all pagesplease help me and dont late...');" title="Sad - ">......thanks   can u give us more information about how ur information is stored in your website so we can help u decide which search mechanism to use? cuz search can be done in a million ways  If this post was useful to you, please mark it as correct answer. Thank yo...

linkbutton->Datalist->Calendar controls
I seem to be having some event bubbling trouble. I have a linkbutton that is in a datalist in a usercontrol. This usercontrol is in placed in each day of the calendar provided a simple condition is true. I've checked my datalist_ItemCommand event yet, it never fires. I'm not sure what's going on now... my usercontrol code <asp:datalist ID="datalist" RepeatDirection="vertical" runat="server" CellPadding="0" CellSpacing="0"> <itemtemplate> <table cellpadding="0"> <tr> ...

New Download>>>>> VERY SLOW
Name: john Email: jsuggatcomcastdotnet Product: Firefox Summary: New Download>>>>> VERY SLOW Comments: when i got on the web this morning with firefox 3.0.6 there was a message that a firefox upgrade had downloaded. now, web pages load VERY, VERY, VERY SLOW. ABOUT 10 TIMES AS LONG TO LOAD, MAYBE MORE. help!! Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish ...

next >> last>>
Hii, I have a datalist that shows students' names from a table. There are 100 names. I don't want to show the whole 100 names at once, instead i want to show only 20 names in a page, then i can see the next 20... and so on.. How can i do that? Can anyont help me? Thanks in advance KOUBBAZ 4 Life!! FYI: http://authors.aspalliance.com/das/datalistpaging.aspx Colt...

Sql Server 2000->->->->->Data->->->-> Sql Server 2005
How can i migrate data from Sql Server 2000 to  Sql Server 2000 A backup file of SQL 2000 can be restored on SQL 2005   ThanksMark post(s) as "Answer" that helped youElectronic ScrewWebsite||Blog||Dub@i.net...

PHP -> JSON ->Zlib -> Delphi XE7 [win32 -> work | android -> No mapping ] [Edit]
Мy program for android should get data from the server as yson when to perform under vindovs works, and in android error, please help! PHP: {code} $err = array(); $data = array('id'=>1,'name'=>'test','info'=>'1234'); $inf = array('data' => $data ,'error' => $err); $json = json_encode($inf); $json = gzencode(trim(preg_replace('/\s+/',' ',$json )),9); header('Content-Encoding: gzip'); header("content-type: text/html; charset: UTF-8"); header("cache-control: must-revalidate&qu...

Web resources about - Find control - Form > FormView > DataList not working - asp.net.web-forms

Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta
In this article, Scott discusses the recently released beta version of Visual Studio 2008 and .NET Framework 3.5 Service Pack 1. He starts with ...

Visual Studio 11 Beta in Context
... data controls. I blogged about this before in my Elegant Web Forms post . There's two way data-binding in controls like the FormView now instead ...

Visual Studio General Questions Forum
Sign in Home Samples Languages Extensions Documentation Community Forums CodePlex User Voice File a Bug Get started for free Visual Studio Developer ...

Advanced Residential Search
HOME MEMBERS WHAT IS WERS LINKS NEWS CONTACT US CERTIFIED PRODUCTS HUB Search Members Members Info Members Area WERS Simulators About WERS FAQs ...

Delicious
Keep, share, and discover the best of the Web using Delicious, the world's leading social bookmarking service.

ASP.NET Web Forms DynamicData FieldTemplates for DbGeography Spatial Types
... - 10 Tutorials Mixing Razor Views and WebForms Master Pages with ASP.NET MVC DbGeography FieldTemplates for ASP.NET Web Forms Here's a FormView ...

Resources last updated: 1/19/2016 12:19:18 AM