Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys, can you help me with my problem regarding about the said subject.

Here's my code:

VB
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!
Posted
Updated 5-Apr-12 0:19am
v2
Comments
ProEnggSoft 5-Apr-12 6:19am    
Edit: pre tag for VB.NET code added - PES
StevensonLee 5-Apr-12 6:38am    
I'm sorry?? I didn't get that. Im a beginner in using visual studio..
vaibhav mahajan 5-Apr-12 6:36am    
check ur code

1 solution

In visual studio put a break point at the line
VB
LabelProductIDviewcheckout.Text = order3.Rows(0)("ProductID")

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
VB
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 
 
Share this answer
 
Comments
StevensonLee 5-Apr-12 8:14am    
Ive applied the code from above, it doesn't make any error now but it won't display the Product ID,Name, Quantity and Price. It just showing the 'Label'

Where can I find data visualizer?
ProEnggSoft 5-Apr-12 8:48am    
In Visual Studio, when code execution is stopped at the break point, if the cursor is hovered over the order3, a tooltip with a magnifier is displayed. Click on the magnifier as shown here http://www.simple-talk.com/dotnet/visual-studio/debugger-visualizers/
Shahin Khorshidnia 5-Apr-12 9:52am    
Good
ProEnggSoft 5-Apr-12 9:56am    
Thank you
StevensonLee 10-Apr-12 5:28am    
sorry for late response. I have clicked the magnifier in which in brings me to dataset visualiser, it only showed the titles and no row can be found.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900