0

我的页面中有 2 个 radgrid。我需要同时更新 2 个 radgrid。当单击 radgrid1 中的按钮时,我需要将该行填充到 radgrid 2,反之亦然。我的代码进行了更新,但我有一个问题,当从radgrid1 lastrow单击按钮时,该行未附加到 radgrid 2 和我也看不到 radgrid 1 中的行。这仅发生在 lastrow 上,类似地,当在 radgrid 2 中单击 lastrow 按钮时,它缺少在我的 radgrid 1 中显示它。否则来自顶部或中间的任何行单击事件只有在单击时才能正常工作在 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>&nbsp 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>
4

1 回答 1

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();
}
于 2013-06-27T10:30:55.567 回答