2010-10-05 21 views
0

这里的情况是:如何在ListVIew的EditTemplate中使用UserControl?

  • 我有一个ListView显示距离数据源的对象的不同领域获得的连接的字符串列表。
  • LinkButton(与CommandName="Edit")每行中
  • OnItemDataBound事件处理程序和OnItemEditing
  • 一个用户控件在EditTemplate

现在的问题是,我不知道如何在UserControl中使用Bind表达式。我的意思是,如何在单击linkbutton时填充此用户控件? (我试图捕捉控制在 OnItemEditing处理程序。但FindControl回到null,作为处理程序之前调用去到编辑模式。)

回答

0

最后得到了asp.net论坛的答案。解决办法是:

  • 修改UserControl,使其支持DataBinding。为此,请执行DefaultBindingPropertyAttributeDetails here.
0
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e) 
{ 
    TheClass theControl = (TheClass)e.Item.FindControl("theControl)"; 
    theControl.someProperty = "bla bla bla"; 
} 
+0

问题是,'e.Item.FindControl(“theControl)”'不会返回usercontrol(在EditTemplate中) – mshsayem 2010-10-07 03:20:17

相关问题