2

例如,我使用 Telerik rad 网格,并将用户列表绑定到它

rgUsers.DataSource = GetUsersList();
rgUsers.DataBind();

我有接收用户对象的用户控件UserEditor

<radG:RadGrid runat="server" ID="rgUsers">
    <MasterTableView>
        <Columns>
          <radG:GridTemplateColumn>
              <ItemTemplate>
                  <asp:Label runat="server" ID="lblName" Text='<%# Eval("username") %>'></asp:Label>
              </ItemTemplate>
              <EditItemTemplate>
                <uc:UserEditor ID="UserEditor" runat="server" User='???????' />
              </EditItemTemplate>
          </radG:GridTemplateColumn>
          ... 

我可以将 User 对象传递给UserEditor,还是必须在 Data Binding 事件中进行?

4

1 回答 1

2

我认为它像原生 ASP.NET 控件一样工作:

RadControls for ASP.NET AJAX 文档 - 事件序列

<radG:RadGrid runat="server" ID="rgUsers" OnItemDataBound="rgUsers_ItemDataBound">  

protected void rgUsers_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item.ItemType == GridItemType.EditItem) 
    {
        User user = (User)e.Item.GridDataItem;
        UserEditor userEditor = (UserEditor )e.Item.FindControl("UserEditor");
        UserEditor.User = user;
    }

}
于 2013-01-11T12:38:17.260 回答