Click here to Skip to main content
15,888,454 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: prevent to copy my web pge Pin
Elham M25-Jul-12 22:21
Elham M25-Jul-12 22:21 
GeneralRe: prevent to copy my web pge Pin
StianSandberg25-Jul-12 22:31
StianSandberg25-Jul-12 22:31 
GeneralRe: prevent to copy my web pge Pin
Elham M26-Jul-12 1:18
Elham M26-Jul-12 1:18 
AnswerRe: prevent to copy my web pge Pin
StianSandberg26-Jul-12 1:52
StianSandberg26-Jul-12 1:52 
GeneralRe: prevent to copy my web pge Pin
RamShankarMCA26-Jul-12 2:12
RamShankarMCA26-Jul-12 2:12 
GeneralRe: prevent to copy my web pge Pin
Elham M26-Jul-12 2:55
Elham M26-Jul-12 2:55 
GeneralRe: prevent to copy my web pge Pin
Pete O'Hanlon26-Jul-12 3:00
mvePete O'Hanlon26-Jul-12 3:00 
QuestionGetting "Index was out of range" error.. Pin
Diana Tsilidi24-Jul-12 9:06
Diana Tsilidi24-Jul-12 9:06 
Hi! I am making an e-shop and i have a search function where you can search for a product in the website. So, it returns the products on the search result page. Then, i want to be able to add the product to cart from the result page. For some reason, the same code i use elsewhere is not working.. i am getting the "Index was out of range. Must be non-negative and less than the size of the collection." error.

Here is my code:

VB
Protected Sub DataList1_ItemCommand(sender As Object, e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.ItemCommand

       Dim currentCommand As String = e.CommandName
       Dim currentRowIndex As Integer = Int32.Parse(e.Item.ItemIndex)
       If currentCommand = "ProductID" Then
           Session("Product") = DataList1.DataKeys(currentRowIndex)
           Response.Redirect("Search.aspx", False)
       ElseIf currentCommand = "AddtoCart" Then
           ' Label2.Text = currentRowIndex
           Session("Product") = DataList1.DataKeys(currentRowIndex)
           ShoppingCart.Instance.AddItem(Session("Product"))
           

Response.Redirect("ViewCart.aspx", False)

       End If
   End Sub



As you can see, i used the Label2 to check the value of the currentRowIndex. In the search i made i had 2 records, for the first one currentRowIndex=0 and for the second currentRowIndex=1.

What am i doing wrong? Smile | :)
AnswerRe: Getting "Index was out of range" error.. Pin
jkirkerx24-Jul-12 10:20
professionaljkirkerx24-Jul-12 10:20 
AnswerRe: Getting "Index was out of range" error.. Pin
Bernhard Hiller24-Jul-12 21:51
Bernhard Hiller24-Jul-12 21:51 
GeneralRe: Getting "Index was out of range" error.. Pin
jkirkerx25-Jul-12 8:45
professionaljkirkerx25-Jul-12 8:45 
GeneralRe: Getting "Index was out of range" error.. Pin
Diana Tsilidi25-Jul-12 9:09
Diana Tsilidi25-Jul-12 9:09 
GeneralRe: Getting "Index was out of range" error.. Pin
jkirkerx26-Jul-12 9:15
professionaljkirkerx26-Jul-12 9:15 
GeneralRe: Getting "Index was out of range" error.. Pin
Diana Tsilidi26-Jul-12 19:32
Diana Tsilidi26-Jul-12 19:32 
QuestionSystem.Byte[] error Pin
Jassim Rahma23-Jul-12 21:41
Jassim Rahma23-Jul-12 21:41 
GeneralRe: System.Byte[] error Pin
Bernhard Hiller24-Jul-12 0:25
Bernhard Hiller24-Jul-12 0:25 
GeneralRe: System.Byte[] error Pin
Jassim Rahma24-Jul-12 3:22
Jassim Rahma24-Jul-12 3:22 
Questionhow to select and read data in dropdownlist? Pin
mohammad ehsan23-Jul-12 19:45
mohammad ehsan23-Jul-12 19:45 
AnswerRe: how to select and read data in dropdownlist? Pin
_Amy24-Jul-12 1:52
professional_Amy24-Jul-12 1:52 
Questionhow can i detect when user click back button in android webkit? Pin
buffering8323-Jul-12 16:29
buffering8323-Jul-12 16:29 
Questionhow to build a project Pin
Harihareshwara23-Jul-12 5:57
Harihareshwara23-Jul-12 5:57 
AnswerRe: how to build a project Pin
Richard MacCutchan23-Jul-12 7:33
mveRichard MacCutchan23-Jul-12 7:33 
AnswerRe: how to build a project Pin
AmitGajjar27-Jul-12 18:06
professionalAmitGajjar27-Jul-12 18:06 
Questioncapture image through Webcam in asp.net 4.0 C#. Pin
ranjitsahani23-Jul-12 1:33
ranjitsahani23-Jul-12 1:33 
AnswerRe: capture image through Webcam in asp.net 4.0 C#. Pin
Richard MacCutchan23-Jul-12 3:18
mveRichard MacCutchan23-Jul-12 3:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.