Click here to Skip to main content
14,266,194 members
Rate this:
Please Sign up or sign in to vote.
See more:
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!
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

In visual studio put a break point at the line
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
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 
   
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.
StevensonLee 10-Apr-12 5:29am
   
what should i do next?
ProEnggSoft 10-Apr-12 19:51pm
   
It means that there are no rows returned by the NewOrder3.GetDataByOrderBasket3(GridView3.SelectedValue.ToString()) method. Check the reason for non return of rows from the above method. Since, NewOrder3 is declared as Dim NewOrder3 As New DataSet1TableAdapters.basket3TableAdapter. Check whether the connection properties are given correctly, whether connection is opened etc. Once, order3.Rows.Count > 0, that means some rows are turned by NewOrder3.GetDataByOrderBasket3, then the values from rows can be displayed in the labels. Please check the above details in the Visual Studio, as it is not possible to see all those details here. Hope this will help you. Thank you.

StevensonLee 11-Apr-12 9:44am
   
How and where can I check the connection properties. I have another labels in other views,same process that i have used and its working fine.

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100