位置0处没有行错误 [英] There is no row at position 0 error
本文介绍了位置0处没有行错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,您能帮我解决有关上述主题的问题吗?
这是我的代码:
Hello guys, can you help me with my problem regarding about the said subject.
Here''s my code:
Protected Sub GridView3_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView3.Selected IndexChanged
MultiView.SetActiveView(ViewCheckout)
Dim NewOrder3 As New DataSet1TableAdapters.basket3TableAdapter
Dim order3 As DataSet1.basket3DataTable
order3=NewOrder3.GetDataByOrderBasket3(GridView3.SelectedValue.ToString())
GridView3.DataBind()
LabelProductIDviewcheckout.Text = order3.Rows(0)("ProductID")
LabelProductNameviewcheckout.Text = order3.Rows(0)("ProductName")
LabelProductQuantityviewcheckout.Text = order3.Rows(0)("ProductQuantity")
LabelProductPriceviewcheckout.Text = order3.Rows(0)("ProductPrice")
谢谢!
Thanks!
推荐答案
在Visual Studio中,在该行处设置一个断点
In visual studio put a break point at the line
LabelProductIDviewcheckout.Text = order3.Rows(0)("ProductID")
并使用data visualizer
检查order3 DataTable
中是否有任何行,因为位置0处没有行错误" 的原因是表中没有行.为避免该错误,请更好地检查order3 DataTable
中的Rows
数量,如下所示
and check whether there are any rows in the order3 DataTable
using the data visualizer
, because the reason for "There is no row at position 0 error" is that there are no rows in the table. To avoid that error better check for the number of Rows
in the order3 DataTable
as below
If order3.Rows.Count > 0 Then
LabelProductIDviewcheckout.Text = order3.Rows(0)("ProductID")
LabelProductNameviewcheckout.Text = order3.Rows(0)("ProductName")
LabelProductQuantityviewcheckout.Text = order3.Rows(0)("ProductQuantity")
LabelProductPriceviewcheckout.Text = order3.Rows(0)("ProductPrice")
End If
这篇关于位置0处没有行错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文