Wizard, goto page, need to set values of a control in a Repeater

Discussion in 'ASP .Net Web Controls' started by David Thielen, May 3, 2006.

  1. Hi;

    Inside a Repeater control I have a DropDownList control. If the user goes
    through the wizard in page order, then in the OnItemCreated method I can set
    the values in the list and it works great.

    However, if they do a prev and change a value on the prev page, then when
    they go back to the page with the Repeater I need to change the values in the
    DropDownList that exists in each row of the Repeater.

    How should I do this?

    --
    thanks - dave
    david_at_windward_dot_net
    http://www.windwardreports.com
     
    David Thielen, May 3, 2006
    #1
    1. Advertising

  2. Hi Dave,

    As for the Repeater control inside the Wizard Step, how did you perform
    databinding on it? Based on my test, when we change the current active Step
    in Wizard control, the certain selected Step will reinit the controls in
    it, and seems we need to repeform the databinding. thus, the ItemCreated or
    ItemDataBound event will fire.

    In addition, for Repeater control after databound, we can use the its
    "Items" collection to loop through all the items in it, and use FindControl
    to locate any sub controls in each RepeaterItem. e.g:

    protected void Button1_Click(object sender, EventArgs e)
    {
    Button btn = sender as Button;
    Repeater rpt = btn.NamingContainer.FindControl("Repeater1") as
    Repeater;

    foreach (RepeaterItem item in rpt.Items)
    {
    Response.Write("<br/>Item: " +
    item.FindControl("list1").ClientID);
    ((DropDownList)item.FindControl("list2")).Enabled = false;
    }
    }


    Hope this helps.

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.



    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], May 3, 2006
    #2
    1. Advertising

  3. RE: Wizard, goto page, need to set values of a control in a Repeat

    Hi;

    Ok, you're right. The problem is a little different.

    If I go to page 0, enter all the info, then click next, it first calls
    Wizard.OnNextButtonClick and then Repeater.OnItemCreated. This works great as
    it is in OnNextButtonClick that I get the data used in OnItemCreated.

    However, if I do not enter all info in page 0, then click the wizard
    shortcut on the right to go to page 1, then the shortcut to go back to page
    0, then enter the info, it calls Repeater.OnItemCreated first and
    Wizard.OnNextButtonClick second. So it is using the old data.

    Is there a way to either: 1) Always get Wizard.OnNextButtonClick called
    first or 2) in Wizard.OnNextButtonClick access each row in the repeater and
    for each row, access a control?

    --
    thanks - dave
    david_at_windward_dot_net
    http://www.windwardreports.com



    "Steven Cheng[MSFT]" wrote:

    > Hi Dave,
    >
    > As for the Repeater control inside the Wizard Step, how did you perform
    > databinding on it? Based on my test, when we change the current active Step
    > in Wizard control, the certain selected Step will reinit the controls in
    > it, and seems we need to repeform the databinding. thus, the ItemCreated or
    > ItemDataBound event will fire.
    >
    > In addition, for Repeater control after databound, we can use the its
    > "Items" collection to loop through all the items in it, and use FindControl
    > to locate any sub controls in each RepeaterItem. e.g:
    >
    > protected void Button1_Click(object sender, EventArgs e)
    > {
    > Button btn = sender as Button;
    > Repeater rpt = btn.NamingContainer.FindControl("Repeater1") as
    > Repeater;
    >
    > foreach (RepeaterItem item in rpt.Items)
    > {
    > Response.Write("<br/>Item: " +
    > item.FindControl("list1").ClientID);
    > ((DropDownList)item.FindControl("list2")).Enabled = false;
    > }
    > }
    >
    >
    > Hope this helps.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Community Support
    >
    >
    > ==================================================
    >
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    >
    > ==================================================
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
     
    David Thielen, May 3, 2006
    #3
  4. RE: Wizard, goto page, need to set values of a control in a Repeat

    Thanks for your response Dave,

    Actually, the event sequence difference between the two times is due to the
    ASP.NET server control's initlize and postback difference. Anyway, after
    your repeater control has been databound, the data is stored in viewstate,
    and when we switching between difference wizards, the repeater won't be
    databound again(just recreate control structure and restore data from
    viewstate). And if you want query or access each row (or a certain nested
    control in each row), you can just use the code I mentioned in last reply.
    e.g:

    =========================================
    protected void Wizard1_NextButtonClick(object sender,
    WizardNavigationEventArgs e)
    {

    if (e.NextStepIndex == 2)
    {
    Repeater rpt = Wizard1.WizardSteps[2].FindControl("Repeater1")
    as Repeater;

    foreach (RepeaterItem item in rpt.Items)
    {
    Response.Write("<br/>Item: " +
    item.FindControl("list1").GetType());

    }
    }

    }
    ========================

    Hope this helps.

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.



    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], May 4, 2006
    #4
    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. Darren Smith
    Replies:
    5
    Views:
    5,547
    dsmith
    May 10, 2004
  2. Replies:
    0
    Views:
    634
  3. Michel Couche
    Replies:
    0
    Views:
    968
    Michel Couche
    Oct 20, 2006
  4. Andy B
    Replies:
    0
    Views:
    459
    Andy B
    Apr 19, 2008
  5. Jens Axel Søgaard
    Replies:
    25
    Views:
    261
Loading...

Share This Page