Hi,
I realy need to iterate all rows. I need to find the the control and then
the selected item.
Here is an exampel I have a survey page and on the page I itterate dynamic
questions. Evrey questiontype has diffrent user control. Ex. onechoice has a
repeater with radiobuttons, multichoice a repater with checkbox.
When I click on the Save button I need to find the select Item and Save. To
find the selected button I have to itterate the repeater.
foreach (RepeaterItem e in repSurveyObject.Items)
{
PlaceHolder plhSurveyObject =
(PlaceHolder)e.FindControl("plhSurveyObject");
if (plhSurveyObject.Controls.Count > 0)
{
// Any better solutions for this? Not nice tho compare
index...
// Can I compare Objects...?
#region OneChoice
if
(plhSurveyObject.Controls[0].ToString().IndexOf("onechoice") != -1)
{
OneChoice onechoice =
(OneChoice)plhSurveyObject.Controls[0];
// Get selected radio and so on....
}
}
Br. Nemo
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
If you create controls dynamically you need to do it again in postback.
What is the functionality you want?
Do you really need to iterate in all the rows of the repeater?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Nemo" <Ne**@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com... Hi,
I have i fishy problem when I have e Repeater with user controls.
page_load
{
if (!isPostBack)
{
repeater.databind();
}
}
A placeholder holds the user controls
When I do postback my Repeater is empty. I don't want to rebind my
computer
on evry posback. The data should be in the viewstate....?
ex.
linkbutton_OnCommand(object sender, CommandEventArgs e)
{
foreach (RepeaterItem e in repSurveyObject.Items)
{
PlaceHolder plh= (PlaceHolder)e.FindControl("plh");
// This is empty... strange. If i remove the lines on page_load
// it works....
}
}
Any nice solution for this problem?