在 Telerik RadGrid 中,用户能够添加行并编辑现有行。看起来网格实际上强制在 UI 控件呈现在屏幕上之前发生回发。我注意到从单击按钮到出现控件的时间有一到两秒的延迟。这似乎太长了一到两秒。这是我的代码,我不太确定错误是什么。
我提前为“我的 codez 帖子出了什么问题”表示歉意,但这似乎是解决此问题的最简单方法。再次,我遇到了性能问题,并且想弄清楚如何通过需要调整哪些代码来解决它......
<asp:UpdatePanel ID="upPhone" runat="server">
<contenttemplate>
<telerik:RadGrid runat="server" ID="gridPhone" DataSourceID="dsPhone" AutoGenerateColumns="False"
Width="100%" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
GridLines="None" Skin="Vista" AllowAutomaticUpdates="True"
ondatabound="gridPhone_DataBound" onitemdeleted="gridPhone_ItemDeleted"
oniteminserted="gridPhone_ItemInserted"
onitemupdated="gridPhone_ItemUpdated"
onneeddatasource="gridPhone_NeedDataSource">
<MasterTableView DataKeyNames="phone_id" CommandItemDisplay="Top"
EditMode="InPlace" AllowFilteringByColumn="False">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
<ItemStyle CssClass="MyImageButton" />
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="phone_id" ReadOnly="true" UniqueName="phone_id"
Visible="false">
</telerik:GridBoundColumn>
<telerik:GridDropDownColumn DataField="d_phone_type_id" DataSourceID="dsPhoneType"
UniqueName="d_phone_type_id" DataType="System.Int32" ListValueField="d_phone_type_id"
ListTextField="name" HeaderText="Type">
</telerik:GridDropDownColumn>
<telerik:GridTemplateColumn HeaderText="Number" SortExpression="number" UniqueName="number">
<ItemTemplate>
<asp:Label runat="server" ID="lblPhoneNumber" Text='<%# Eval("number", "{0:(###) ###-####}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtNumber" MaxLength="10" runat="server" Text='<%# Bind("number") %>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="description" UniqueName="description" HeaderText="Description">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn DataField="isprimary" UniqueName="isprimary" HeaderText="Primary"
DataType="System.Int16">
</telerik:GridCheckBoxColumn>
<telerik:GridButtonColumn ConfirmText="Delete this number?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="DeleteColumn">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings>
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" />
</ClientSettings>
</telerik:RadGrid>
<asp:ObjectDataSource ID="dsPhoneType" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetPhoneTypes"
TypeName="DataAccess"></asp:ObjectDataSource>
<asp:SqlDataSource ID="dsPhone" runat="server" ConnectionString="<%$ ConnectionStrings:TBD %>"
DeleteCommand="DELETE FROM [phone] WHERE [phone_id] = @phone_id" InsertCommand="INSERT INTO [phone] ([person_id],[d_phone_type_id], [number], [description], [isprimary]) VALUES (@person_id,@d_phone_type_id, @number, @description, @isprimary)"
SelectCommand="get_PhoneById" UpdateCommand="UPDATE [phone] SET [d_phone_type_id] = @d_phone_type_id, [number] = @number, [description] = @description, [isprimary] = @isprimary WHERE [phone_id] = @phone_id"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="lblID" Name="person_id" PropertyName="Text" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="phone_id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="d_phone_type_id" Type="Int32" />
<asp:Parameter Name="number" Type="Int64" />
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="isprimary" Type="Boolean" />
<asp:Parameter Name="phone_id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:ControlParameter ControlID="lblID" Name="person_id" PropertyName="Text" />
<asp:Parameter Name="d_phone_type_id" Type="Int32" />
<asp:Parameter Name="number" Type="Int64" />
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="isprimary" Type="Boolean" />
</InsertParameters>
</asp:SqlDataSource>
</contenttemplate>
</asp:UpdatePanel>
最佳答案
只需检查几件事:
您是否复制 gridPhone_NeedDataSource 事件、ItemUpdated、Deleted 和 Inserted 事件以及 native Rad Grid 绑定(bind)行为(通过使用 asp:SqlDataSource 控件)中的绑定(bind)行为?这会很有用查看您的代码隐藏,看看您是否是。
网格中有多少条记录?我发现网格中是否有大量项目并且打开了一些高级功能(我注意到您已经启用行选择)网格逐渐停止。
如果这些都不起作用/不适用于您的情况,那么也许值得检查 performance section他们的网站。
关于asp.net - Telerik RadGrid 添加/编辑行性能问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1918601/