我有一个绑定到对象集合的转发器控件。当我触发 button_onclick 事件时,我需要访问数据项以获取对象属性。这是我所拥有的,我的问题是如何在 button_onclick 事件中访问转发器中的底层对象
protected void OKButton_Click(object sender, EventArgs e)
{
try
{
string selectedValue = Request.Form["repeaterRadioButton"];
foreach (RepeaterItem item in Repeater1.Items)
{
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
MyObject myObject = (MyObject)item.DataItem;
if (!string.IsNullOrEmpty(selectedValue) && selectedValue == myObject.MyProperty)
{
//stuff in here
} ... rest of code