3

在 Telerik RadGrid 中,用户可以添加行和编辑现有行。看起来网格实际上强制在 UI 控件呈现在屏幕上之前发生回发。我注意到从单击按钮到出现控件的时间之间存在一到两秒的延迟。这似乎太长了大约一到两秒。这是我的代码,我不确定是什么错误。

我提前为“whatz wrongz with me codez post”道歉,但这似乎是解决这个问题的最简单方法。同样,我有一个性能问题,想弄清楚如何根据需要调整哪些代码来解决它.....

<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>
4

2 回答 2

1

只需检查几件事:

您是否复制了 gridPhone_NeedDataSource 事件、ItemUpdated、Deleted 和 Inserted 事件以及本机 Rad Grid 绑定行为(通过使用 asp:SqlDataSource 控件)中的绑定行为?查看您的代码隐藏以查看您是否是很有用的。

网格中有多少条记录?我发现如果我在网格中有大量项目并且打开了一些高级功能(我注意到你已经启用了行选择),那么网格就会停止。

如果这些都不起作用/不适用于您的情况,那么可能值得检查他们网站的性能部分

于 2009-12-17T10:33:12.800 回答
1

我看到你正在使用DataSourceID="dsPhone"onneeddatasource="gridPhone_NeedDataSource"

不确定你是否需要两者。还要确保您不在代码中的其他位置(page_Load 或任何其他位置)执行 DataBind(),因为您已经将 OnNeedDataSource 事件附加到网格

于 2009-12-17T19:38:18.210 回答