以下のコード スニペットで試してください。
.aspx
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" OnItemDataBound="RadGrid1_ItemDataBound"
OnNeedDataSource="RadGrid1_NeedDataSource" AllowFilteringByColumn="true"
PageSize="2" AllowPaging="true" onpagesizechanged="RadGrid1_PageSizeChanged">
<MasterTableView Name="Parent" DataKeyNames="ID" EditMode="PopUp">
<Columns>
<telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
</telerik:GridBoundColumn>
<telerik:GridEditCommandColumn>
</telerik:GridEditCommandColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadGrid ID="RadGrid2" runat="server" AutoGenerateColumns="False" OnNeedDataSource="RadGrid2_NeedDataSource" onpagesizechanged="RadGrid2_PageSizeChanged"
PageSize="2" AllowPaging="true">
<MasterTableView Name="Parent" DataKeyNames="ID" EditMode="PopUp">
<Columns>
<telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
.aspx.cs
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
dynamic data = new[] {
new { ID = 1, Name ="Name1",path="1.jpg"},
new { ID = 2, Name = "Name2",path="2.jpg"},
new { ID = 3, Name = "Name3",path="3.jpg"},
new { ID = 4, Name = "Name4",path="2.jpg"},
new { ID = 5, Name = "Name5",path="3.jpg"}
};
RadGrid1.DataSource = data;
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item.IsInEditMode && e.Item is GridEditableItem)
{
GridEditableItem item = e.Item as GridEditableItem;
string strID = item.GetDataKeyValue("ID").ToString();
// Access your DataKey here
}
}
protected void RadGrid2_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
dynamic data = new[] {
new { ID = 1, Name ="Name1",path="1.jpg"},
new { ID = 2, Name = "Name2",path="2.jpg"},
new { ID = 3, Name = "Name3",path="3.jpg"},
new { ID = 4, Name = "Name4",path="2.jpg"},
new { ID = 5, Name = "Name5",path="3.jpg"}
};
RadGrid2.DataSource = data;
}
protected void RadGrid1_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
{
RadGrid2.PageSize = e.NewPageSize;
RadGrid2.Rebind();
}
protected void RadGrid2_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
{
RadGrid1.PageSize = e.NewPageSize;
RadGrid1.Rebind();
}