我的页面中有2个radgrid。我需要同时更新2个radgrids。当单击radgrid1中的按钮时,我需要将行填充到radgrid 2,反之亦然。我的代码执行更新但是我有一个问题,当从 radgrid1 lastrow 单击按钮时,该行是没有附加到radgrid 2,我也没有看到radgrid 1中的行。这也只发生在lastrow上,同样当一个lastrow按钮在radgrid 2中点击时它缺少在我的radgrid中显示它1.来自顶部的任何行clickevent或者midrow只有在点击lastrow时才能正常工作,我看到它丢失并出现在下一个toprow点击的行中。我需要知道造成这种不当行为的原因仅在我的radgrid lastrow上。
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Default" EnableRoundedCorners="False" DecoratedControls="All" />
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadGrid2">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadGrid1LinkButton">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadGrid2LinkButton">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
<telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
<h3 style="text-align:left"><i class="icon-group"></i>  Shared With</h3><br />
<telerik:RadGrid ID="RadGrid1"
Width="100%" OnNeedDataSource="RadGrid1_NeedDataSource" AllowSorting="True" DataKeyNames="CartId"
PageSize="10" AutoGenerateColumns="false" AllowPaging="True" AllowMultiRowSelection="True" runat="server" GridLines="None">
<MasterTableView Width="100%" AllowMultiColumnSorting="true" Summary="RadGrid table" DataKeyNames="CartId">
<Columns>
<telerik:GridTemplateColumn UniqueName="UserNameTemplateColumn" HeaderText="UserName" SortExpression="UserName" >
<ItemTemplate>
<asp:Label ID="UserNamelbl" runat="server" Text='<%# Eval("UserName")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="DateTemplateColumn" HeaderText="Date" SortExpression="Date" >
<ItemTemplate>
<asp:Label ID="RequestDate" runat="server" Text='<%# Eval("Date")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn1" HeaderText="add user"
AllowFiltering="false">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:LinkButton ID="RadGrid1LinkButton"
OnCommand="AddUser" CommandName="AddUser" runat="server" CommandArgument='<%# Eval("CartId")%>' >
</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
</telerik:RadGrid>
<telerik:RadGrid ID="RadGrid2" OnNeedDataSource="RadGrid2_NeedDataSource" AllowSorting="True" DataKeyNames="CartId"
PageSize="10" AutoGenerateColumns="false" AllowPaging="True" AllowMultiRowSelection="True" runat="server" GridLines="None">
<MasterTableView Width="100%" AllowMultiColumnSorting="true" Summary="RadGrid table" DataKeyNames="RecepientlearningCartId">
<Columns>
<telerik:GridTemplateColumn UniqueName="UserNameTemplateColumn" HeaderText="UserName" SortExpression="UserName" >
<ItemTemplate>
<asp:Label ID="UserNamelbl" runat="server" Text='<%# Eval("UserName")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="DateTemplateColumn" HeaderText="Date" SortExpression="Date" >
<ItemTemplate>
<asp:Label ID="Date" runat="server" Text='<%# Eval("Date")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn1" HeaderText="Revoke Share"
AllowFiltering="false">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:LinkButton ID="radGrid2LinkButton"
OnCommand="Removeuser" CommandName="Removeuser" runat="server" CommandArgument='<%# Eval("CartId")%>' >
</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
</telerik:RadGrid>
答案 0 :(得分:0)
请尝试使用以下代码段。
.ASPX
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadGrid2">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid1" Width="100%" OnNeedDataSource="RadGrid1_NeedDataSource"
AllowSorting="True" DataKeyNames="ID" PageSize="10" AutoGenerateColumns="false"
AllowPaging="True" AllowMultiRowSelection="True" runat="server" GridLines="None">
<MasterTableView Width="100%" AllowMultiColumnSorting="true" Summary="RadGrid table"
DataKeyNames="ID">
<Columns>
<telerik:GridTemplateColumn UniqueName="UserNameTemplateColumn" HeaderText="UserName"
SortExpression="UserName">
<ItemTemplate>
<asp:Label ID="UserNamelbl" runat="server" Text='<%# Eval("Name")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="DateTemplateColumn" HeaderText="Date" SortExpression="Date">
<ItemTemplate>
<asp:Label ID="RequestDate" runat="server" Text='<%# Eval("Name")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn1" HeaderText="add user" AllowFiltering="false">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:LinkButton ID="RadGrid1LinkButton" OnCommand="AddUser" CommandName="AddUser"
Text="click here" runat="server" CommandArgument='<%# Eval("ID")%>'>
</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
</telerik:RadGrid>
<telerik:RadGrid ID="RadGrid2" OnNeedDataSource="RadGrid2_NeedDataSource" AllowSorting="True"
DataKeyNames="CartId" PageSize="10" AutoGenerateColumns="false" AllowPaging="True"
AllowMultiRowSelection="True" runat="server" GridLines="None">
<MasterTableView Width="100%" AllowMultiColumnSorting="true" Summary="RadGrid table"
DataKeyNames="ID">
<Columns>
<telerik:GridTemplateColumn UniqueName="UserNameTemplateColumn" HeaderText="UserName"
SortExpression="UserName">
<ItemTemplate>
<asp:Label ID="UserNamelbl" runat="server" Text='<%# Eval("Name")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="DateTemplateColumn" HeaderText="Date" SortExpression="Date">
<ItemTemplate>
<asp:Label ID="Date" runat="server" Text='<%# Eval("Name")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn1" HeaderText="Revoke Share"
AllowFiltering="false">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:LinkButton ID="radGrid2LinkButton" OnCommand="Removeuser" CommandName="Removeuser"
Text="click here" runat="server" CommandArgument='<%# Eval("ID")%>'>
</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
</telerik:RadGrid>
.ASPX.CS
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
dynamic data = new[] {
new { ID = 1, Name =DateTime.Now.ToString()},
new { ID = 2, Name = "Name2"},
new { ID = 3, Name = "Name3"},
new { ID = 4, Name = "Name4"},
new { ID = 5, Name = "Name5"}
};
RadGrid1.DataSource = data;
}
protected void RadGrid2_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
dynamic data = new[] {
new { ID = 1, Name =DateTime.Now.ToString()},
new { ID = 2, Name = "Name2"},
new { ID = 3, Name = "Name3"},
new { ID = 4, Name = "Name4"},
new { ID = 5, Name = "Name5"}
};
RadGrid2.DataSource = data;
}
protected void AddUser(object sender, CommandEventArgs e)
{
RadGrid1.Rebind();
RadGrid2.Rebind();
}
protected void Removeuser(object sender, CommandEventArgs e)
{
RadGrid1.Rebind();
RadGrid2.Rebind();
}