Search code examples
c#asp.netrepeater

Get Repeater data with foreach


I have a Repeater in my page and after databinding, I have to click on a button to postback in page, and I need to do a foreach in all data from my Repeater. In true I have to get each item inside foreach statment as example.

foreach (RepeaterItem itemEquipment in rptSpecialEquipments.Items)
{
   // Get Data From My Repeater
}

Best Regards,

Milton Câmara Gomes


Solution

  • Is this what you want?

        foreach (RepeaterItem itemEquipment in rptSpecialEquipments.Items)
        {
            //to get the dropdown of each line
            DropDownList yourDropDown = (DropDownList)item.FindControl("the name of your dropdown control here");
    
            //to get the selected value of your dropdownlist
            string value = yourDropDown.SelectedValue;
        }