- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个使用 gridview 的应用程序,它非常慢。
添加 Trace=true
后对于页面,我追踪了时间花费的地方:在 GridView 上调用 BindData() 时。 GridView
连接到 LinqDataSource
.
这是跟踪输出:
GetContact 0.955485090710761 0.000339
DataBind 0.97438854173692 0.018903
PopulateStates 6.58986882347249 5.615480
这是示例 asp.net 页面
<asp:LinqDataSource ContextTypeName="DAL.BALDataContext" TableName="loc_access_contacts"
ID="_ldsContact" runat="server" OrderBy="organisation, last_name, first_name">
</asp:LinqDataSource>
<cc1:CustomGridView ID="gvContact" runat="server" DataSourceID="_ldsContact" AutoGenerateColumns="False" Width="100%"
DataKeyNames="person_id" ForeColor="#333333" GridLines="None" AllowPaging="False"
AllowSorting="True" BorderStyle="None" ShowFooter="false" CaptionAlign="Top"
PagerStyle-HorizontalAlign="Left" HeaderStayPolicy="NotStay" SessionKey="Contact.GridView.Columns.SortSettings"
SaveKey="ContactManagementSortSettings" OnRowCommand="gvContact_RowCommand" OnSorting="gvContact_Sorting">
在代码隐藏中:
Trace.Write(" DataBind");
gvContact.DataBind();
Trace.Write(" PopulateStates");
populateStates(contact);
LINQ 数据源代码如下所示:
public System.Data.Linq.Table<loc_access_contact> loc_access_contacts
{
get
{
return this.GetTable<loc_access_contact>();
}
}
从此属性生成的 SQL 是规范的 SELECT <all fields> FROM loc_access_contact
.
和表loc_access_contact
看起来像:
CREATE TABLE [dbo].[loc_access_contact](
[person_id] [int] IDENTITY(1,1) NOT NULL,
[organisation] [nvarchar](50) NULL,
[last_name] [nvarchar](50) NULL,
[first_name] [nvarchar](50) NULL,
[is_active] [tinyint] NULL,
[state_id] [char](2) NULL,
[postal_code] [nchar](4) NULL,
[town] [nvarchar](50) NOT NULL,
[phone_number] [nvarchar](20) NULL,
[mobile_number] [nvarchar](20) NULL,
[fax_number] [nvarchar](20) NULL,
[email_address] [nvarchar](255) NULL,
[street_name] [nvarchar](255) NULL,
[house_number] [nvarchar](20) NULL,
[postal_box] [nvarchar](20) NULL,
[language] [tinyint] NULL,
CONSTRAINT [PK_person] PRIMARY KEY CLUSTERED
(
[person_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
该表包含大约 287 个联系人。
为什么 DataBind 这么慢?我如何才能进一步追踪正在发生的事情?
最佳答案
如果您使用的是 SQL Server - 我会跟踪应用程序然后再次运行。然后我会挑选出实际运行的 SQL。直接在数据库上运行,然后看看是否可以发现瓶颈。
看起来您正在带回 loc_access_contacts
中的所有数据,所以它可能是绝对数据量。
另一个可能是排序。您正在按组织、姓氏、名字排序。我很想在这些列上放置一个非聚集索引以帮助提高排序效率。请检查此表是否具有合理的聚集索引,即主键。
当然,我在这里假设您可以控制您的数据库,我知道很多人都没有。在那种情况下(或者在任何情况下老实说)在你的网格中使用分页。如果您可以使用某种合理的服务器端分页(即通过使用 Skip
和 Take
LINQ 运算符),这将大大提高您的绑定(bind)效率。它们将只是少得多的数据。
关于c# - Gridview 上的 DataBind() 速度慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9567258/
我正在尝试在 android 中学习 ViewModel,在我的第一阶段学习中,我正在尝试使用 ViewModel 和 DataBinding 来更新 UI(TextView)。在 ViewModel
在 ASP.NET 中,您可以单独绑定(bind)控件(即 GridView1.DataBind() ),也可以调用 Page.DataBind()绑定(bind)页面上的所有控件。 这两个调用之间有
如何使用新的 dataBinder 插件进行双向绑定(bind)(从 UI 到数据以及从数据到 UI)? 非常感谢! 最佳答案 我们还没有这个,也许在 v1 之后。不确定您的用例是什么,但我们已经为每
我正在尝试将 Kotlin 与 DataBinding 一起使用,但我遇到了这个错误: Error:[kapt] An exception occurred: java.lang.annotation
我只是将我的项目转换为 androidX 并成功构建项目。但是当我想运行那个时间时,它在启用了 java 的 android studio 3.5.3 中创建了这个错误。 这是我的项目 gradle:
这个问题在这里已经有了答案: no cached version available for offline mode (11 个回答) 2年前关闭。 无法确定任务的依赖关系 :app:compile
这是一个与今天无关的老问题。请参阅 Android 开发人员的说明。与四年前相比,现在将数据绑定(bind)应用于您的项目要容易得多。 我正在阅读 https://developer.android.
异常(exception)情况如下: java.lang.NullPointerException: Attempt to read from field 'java.lang.Runnable an
构建项目时收到以下警告 DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'androi
今天升级Android Studio 2.3后,构建项目失败。 当构建项目 gradle console 显示这个错误: FAILURE: Build failed with an exception
我有一个消息列表,我将这些消息的模板绑定(bind)到单击事件中,然后在该模板内,我有一个超链接绑定(bind)到 js 函数,该函数应该打开一个 mailto 页面。 但是,尽管 js 函数执行,但
我在 Wildfly 8.2.1 和 Glassfish 4.1 中使用 Spring Data JPA 部署 Spring MVC 应用程序时遇到问题(它在 Wildfly 10 中工作,但我不允许
我为横向创建了一个替代布局 XML 文件。使用 DataBindingUtil 的填充在纵向模式下工作正常,但在加载自定义 XML 文件时在横向模式下崩溃。 使用数据绑定(bind)的布局膨胀: cl
数据绑定(bind)到控件的可见属性时是否存在任何已知问题? 无论我的属性是什么,该控件始终不可见。 Public ReadOnly Property IsRibbonCategory() As Bo
使用数据绑定(bind),如何绑定(bind)使用值类型的新对象? 简单的例子: public class Person() { private string _firstName;
我有一个 Image 控件,它的源绑定(bind)到对象上的属性(字符串 url 到图像)。进行服务调用后,我使用新 URL 更新数据对象。在调用 PropertyChanged 事件后,它离开我的代
我想在传入的绑定(bind)整数上添加一个常量值。事实上,我有几个地方想要绑定(bind)到相同的源值但添加不同的常量。所以理想的解决方案是这样的...... (注意:这是一个展示这个想法的例子
我正在开发一个 Windows Phone 应用程序。我将 List 绑定(bind)到内容控制元素。 在转换器中,我返回指定参数的字符串。
天哪!我讨厌这个。为什么这么复杂? 我正在尝试做的事情: 我有一个包含多个用户控件的表单,每个控件都有一个数据网格。每个网格通过 .ItemSource 属性与 ObservableCollectio
我正在使用数据绑定(bind)并且我已经声明了 lateinit var对于绑定(bind)以及当我要去不同的 fragment Leaky canary 显示泄漏时。 fragment class
我是一名优秀的程序员,十分优秀!