Pass data into .NET Web Part?

Discussion in 'ASP .Net' started by =?Utf-8?B?RGF2ZQ==?=, Mar 29, 2007.

  1. I have a aspx page that I want to pass data into dynamically created
    webparts. Each web part will contain a user control I created
    (WebUserControl1) that exposes a public property (.TestData). This property
    then sets a label control on Web Part's user control....

    WebUserControl1 mycontrol =
    (WebUserControl1)LoadControl("WebUserControl1.ascx");
    mycontrol .TestData= "test data passed to webpart's usercontrol";
    mycontrol .ID = "control";

    WebPart myWebPart = WebPartManager1.CreateWebPart(mycontrol);
    myWebPart.Title = "Some Title";
    WebPartManager1.AddWebPart(myWebPart, WebPartManager1.Zones[0], 0);

    But when the page renders, the webpart is created in the zone, with the
    title and user control, but the data passed seems to get lost and is never
    setting the label inside.

    What am I doing wrong? Thanks, Dave.
     
    =?Utf-8?B?RGF2ZQ==?=, Mar 29, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harry Zoroc
    Replies:
    1
    Views:
    978
    Gregory Vaughan
    Jul 12, 2004
  2. Replies:
    0
    Views:
    298
  3. Replies:
    1
    Views:
    319
  4. Dave

    Pass data to asp.net 2.0 web part?

    Dave, Apr 2, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    144
  5. Jack
    Replies:
    8
    Views:
    299
Loading...

Share This Page