从ListView数据源访问当前项

时间:2011-01-23 09:07:35

标签: c# asp.net listview datasource

我认为这不会太难做,但我似乎无法弄清楚如何去做。有没有办法从ListView数据源轻松访问当前项?例如,您可以使用Eval("propertyName")轻松评估当前项目的属性,但有没有办法访问对象本身?

如果这是不可能的,我最终想做的是获取对象的类型。

1 个答案:

答案 0 :(得分:1)

使用 FindControl 方法。

例如,

int index=0; // obtain the index of an item. 
TextBox num = (TextBox)ListView1.Items[index].FindControl("numTextBox");
相关问题