是否可以在同一页面上使用多个列表视图 [英] Is it Possible to use more than one listview on the same page

查看:84
本文介绍了是否可以在同一页面上使用多个列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助......我对asp.net有点新意,我正在学习使用数据控件。我想知道是否可以在asp.net的同一页面上使用多个listview项目?我在同一页面上有两个listview控件,并且两个绑定到不同的数据源。在页面加载时,只有一个列表视图显示数据,另一个不显示记录/数据。如果有可能我想知道如何做到这一点。







这是我的代码:

Please help... I'm a bit new to asp.net and i'm learning to work with data controls. I would like to know if it's possible to work with more than one listview item on the same page in asp.net? I have two listview controls on the same page and both of the bound to different data sources. On page load only one listview displays data, the other one doesn't show record/data. If it's possible i would like to know how to do it.



Here's my code:

Dim DA As New SqlDataAdapter(Query, conn)
DA.SelectCommand.Parameters.AddWithValue("@borrower_id", BorrowerID)
DA.SelectCommand.Parameters.AddWithValue("@bank_id", BankID)
Dim DS As New DataSet

DA.Fill(DS)

lvDetails.DataSource = DS.Tables(0)
lvDetails.DataBind()




Dim insertCommand As New SqlCommand(Query, conn)
insertCommand.Parameters.AddWithValue("@f_name", DS.Tables(0).Rows(0).Item("First_name"))
insertCommand.Parameters.AddWithValue("@l_name", DS.Tables(0).Rows(0).Item("First_name"))
insertCommand.Parameters.AddWithValue("@customer", DS.Tables(0).Rows(0).Item("customer_name"))
Dim DA1 = New SqlDataAdapter(insertCommand)

Dim DS1 As New DataSet
DA1.Fill(DS1)

otherDetails.DataSource = DS1.Tables(0)
otherDetails.DataBind()





第二个列表视图不显示任何数据。



The second listview doesn't show any data.

推荐答案

尝试更改

Try changing from
insertCommand.Parameters.AddWithValue("@f_name", DS.Tables(0).Rows(0).Item("First_name"))
insertCommand.Parameters.AddWithValue("@l_name", DS.Tables(0).Rows(0).Item("First_name"))
insertCommand.Parameters.AddWithValue("@customer", DS.Tables(0).Rows(0).Item("customer_name"))



to


to

insertCommand.Parameters.AddWithValue("@f_name", DS.Tables(0).Rows(0).Item("First_name"))
insertCommand.Parameters.AddWithValue("@l_name", DS.Tables(0).Rows(0).Item("Last_name"))
insertCommand.Parameters.AddWithValue("@customer", DS.Tables(0).Rows(0).Item("customer_name"))



我只是猜测 Last_name 是正确的列名。



请注意,这不是一个好的编码方式。

使用所有这些硬编码索引,最终会遇到错误。


I am just guessing that Last_name is the proper column name.

Be advised that this is not a good way to code.
With all these hard coded indexes you are bound to run into errors eventually.


这篇关于是否可以在同一页面上使用多个列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆