|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Wizard, goto page, need to set values of a control in a RepeaterHi;
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? 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.) 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? Show quoteHide quote "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.) > > 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.)
Push Button Event in datagrid
FileUpload, Wizard, and saving the data Web Standards Compliance - Autopostback / Javascript off Set file extensions for FileUpload delete rows in dataset Custom Web Control and Default Height/Width Dynamic Menu Control in ASP.NET2 User Control question - REPOSTED "Unable to open the physical file" error Creating Dynamic FormView Templates |
|||||||||||||||||||||||