Reputation: 753
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
Upvotes: 2
Views: 25960
Reputation: 11
when you are declaring RepeaterItem as itemEquipment then (dropDownList) should be be found in itemEquipment not item
so correct code would be as below. I tried to edit the answer above but the person who reviewed it rejected by edition.
foreach (RepeaterItem itemEquipment in rptSpecialEquipments.Items)
{
//to get the dropdown of each line
DropDownList yourDropDown = (DropDownList)itemEquipment.FindControl("the name of your dropdown control here");
//to get the selected value of your dropdownlist
string value = yourDropDown.SelectedValue;
}
Upvotes: 1
Reputation: 3147
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;
}
Upvotes: 5