How to Get Controls that created dynamically in code behind

ManoNagarajanManoNagarajan ✭✭USMember ✭✭

How do i find controls?

public partial class RecordDetails : ContentPage
{
public RecordDetails(){
StackLayout st=new StackLayout();
st.Children.Add(CreateDummyLayout("0"));
st.Children.Add(CreateDummyLayout("1"));
st.Children.Add(CreateDummyLayout("2"));
Content=st;
}
public StackLayout CreateDummyLayout(string index)
{
var slContainer = new StackLayout
{
StyleId = "layout " + index ,
HorizontalOptions = LayoutOptions.FillAndExpand
};

        for (int ctlCnt = 0; ctlCnt < 12; ctlCnt++)
        {
            slContainer.Children.Add(
                           new Label
                           {

                               Text = "Field Label " + index + " " + ctlCnt,
                               HorizontalOptions = LayoutOptions.FillAndExpand
                           });
            slContainer.Children.Add(new Entry
            {

                StyleId = "Field " + index + " " + ctlCnt,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Placeholder = "Field " + index + " " + ctlCnt
            });
        }
        return slContainer;
    }

}

Answers

  • ManoNagarajanManoNagarajan ✭✭ USMember ✭✭

    I want to do calculations in fields. Based on data from database i have to do add/Subtract/Multiplication and division on dynamically created fields.
    Ex: SumField=Field1+Field2

    To achieve this i have to find appropriate controls to bind value.

Sign In or Register to comment.