- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试按文本框名称 PostCode1 从 SQLDataSource POSTCODE_Data 中过滤数据。
我通过使用 .Rowfilter
属性来执行此操作,但它不起作用。结果 POSTCODE_Data 仍未过滤。
我需要做什么才能得到想要的结果?
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dv As DataView
Dim recPostDes As String
Dim recMiles As Integer
dv = CType(POSTCODE_Data.Select(DataSourceSelectArguments.Empty), DataView)
dv.RowFilter = "POSTCODE = '" & PostCode1.Text & "%'"
recPostDes = CType(dv.Table.Rows(0)(3), String)
recMiles = CType(dv.Table.Rows(0)(5), Integer)
If recMiles > 0 Then
Des1.Text = recPostDes
Mile1.Text = recMiles
End If
End Sub
最佳答案
首先,看起来您正在尝试创建一个 Like表达。如果是这样,将 =
更改为 Like
dv.RowFilter = "POSTCODE Like '" & PostCode1.Text & "%'"
DataView
"Represents a databindable, customized view of a DataTable for sorting, filtering, searching, editing, and navigation. The DataView does not store data, but instead represents a connected view of its corresponding DataTable. Changes to the DataView’s data will affect the DataTable. Changes to the DataTable’s data will affect all DataViews associated with it." - MSDN -
现在,这是您的问题:您访问的是基础表 (dv.Table
) 而不是 View 。
recPostDes = CType(dv.Item(0).Row.Item(3), String)
recMiles = CType(dv.Item(0).Row.Item(5), Integer)
或者
recPostDes = CType(dv(0)(3), String)
recMiles = CType(dv(0)(5), Integer)
关于mysql - 如何从 SQLDataSource 中过滤数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31352982/
我有一个 SqlDataSource,我正在尝试向其添加 UpdateCommand,以便在选择 GridView 的更新按钮时调用存储过程。我在后面的代码中执行此操作,因为我需要调用两个过程之一,具
我正在使用 SqlDataSource 来填充 GridView。这是我的代码: private void DataCall() { //Object gets created for use
作为我在所有业务应用程序中使用的常用实用程序的一部分,我有这段代码... using System.Web.UI.WebControls; public class Database {
我在我的应用程序中使用 SqlDataSource 来填充下拉列表,我在 Visual Studio 的网页设计中配置它。 我希望这个下拉列表会根据 sql 中的几个表动态变化。 可以从代码中以编程方
使用 .NET 4 和 C#。所有这些都会引发错误: sdsTypeinfo.SelectParameters.Add("@TypeCode", DbType.Boolean, DBNull.Valu
我偶然发现了一个问题,无法自己解决。希望有人能帮我解决。 所以,我在 SQL Server 2005 数据库中有一个简单的存储过程 CREATE PROCEDURE spTest @pin var
我一直有这样的想法,与使用 SqlDataSource 编写 SQL 查询相比,在后面的代码中编写 SQL 查询并不好 SqlDataAdapter ad = new SqlDataAdapter("
如果网页需要一些数据,为什么不让 SQLDataSource 调用存储过程呢?为什么要使用 ObjectDataSource 调用业务对象,然后再调用存储过程?我知道基于 .net 框架构建的其他应用
是否有一种合理的方法可以从 SqlDataSource 获取预期参数列表(给定分配给其 SelectCommand 属性的存储过程的名称)? 最佳答案 您可以使用 SqlCommandBuilder.
我有以下 SqlDataSource " InsertCommand="INSERT INTO [Chat] ([Username], [Message]) VALUES (@User
我有一个 SqlDataSource 正在向我的 GridView 提供数据。这就是我在表单上使用的所有内容,因此我根本没有任何代码。但在某个地方我需要一个 TRY CATCH block ,以防万一
我是 ASP.net 的新手,目前正在阅读有关 SqlDataSource 的内容并正在运行一些示例。我正在与一位同事交谈,他说它“适用于快速和肮脏的应用程序”,但没有人会在生产/部署环境中使用它。
假设我在 .aspx 页面上有某种数据网格或转发器,并且我的数据源是内联定义的,如下所示: 如何调试我的代码,以便我可以准确地看到 Year 绑定(bin
所以我有一个 GridView 设置为 SqlDataSource。分页已启用,我有一个下拉菜单,可以更改每页显示的行数。我可以获得单个页面中显示的总行数,但我也想显示总行数。 (像这样:“显示 31
我正在创建一个 ASP.NET/C# 页面,用户在页面顶部输入一个 ID,当他们按下提交时,页面回发并显示数据。现在,数据字段始终显示 - 即使在页面加载且未进行搜索时也是如此。这并不理想,因为当他们
我有一个 FormView,下面有一个 UpdateButton 和一个 SqlDataSource。我的 updatebutton 总是用相同的值(我的 gridview 第一行的值)更新 Sil
我有一个绑定(bind)到 SqlDataSource 的 GridView。我在执行 UpdateCommand 时遇到问题,它似乎执行了两次。当我单步执行 gvChecklist_RowUpdat
我有一个带有 OnInserted 处理程序的 SqlDataSource。处理程序发送一封电子邮件,其中包含从 Inserted 记录中收集的数据。包括它的 ID(输出参数)。 昨天,我收到处理程序
我有一个 Microsoft SQL 数据库和一个 MySQL 数据库,我需要将它们加入并放入 GridView 中。 到目前为止,我已经成功地使用了 ASP 和 SqlDataSource,如下所示
我正在尝试按文本框名称 PostCode1 从 SQLDataSource POSTCODE_Data 中过滤数据。 我通过使用 .Rowfilter 属性来执行此操作,但它不起作用。结果 POSTC
我是一名优秀的程序员,十分优秀!