Google seems to think I should be able to do this: Basically I'm creating textboxes/checkboxes in a listview in code behind and I'm try to get their values. Easy enough, each item has a panel and in that is a hiddenfield with the id value and a textbox or checkbox.
On post back I'm recreating the controls and then searching for the values, by iterating through each item and checking for values. But I can't find the controls within the panel.
Here is my watch panel when it claims it can't find my control by ID:
Here's the code to find the control:
foreach(var item in lvAssetProperties.Items)
{hfPropID = item.FindControl("hfPropID") as HiddenField;
int id;
if (int.TryParse(hfPropID.Value, out id))
{
prop = ctx.Properties.FirstOrDefault(p => p.id == id);
if (prop.Type_Property.Select(t => t.Type.id).Contains(type.id))
{
var cnt = item.FindControl(string.Format("Prop_{0}", prop.id));
if (cnt is TextBox)
{
var value = (cnt as TextBox).Text;
}
}
}
}