0
  protected void ordersGV_SelectedIndexChanged(object sender, EventArgs e)
    {
        orderdetails_lbl.Visible = true;
        int orderId=int.Parse(ordersGV.SelectedRow.Cells[1].Text);
        var query = nw.Order_Details.Where(od => od.OrderID == orderId).Select(od=>new {od.Product.ProductName,od.Quantity });
        orderdetailsGV.DataSource = query.ToList();
        orderdetailsGV.DataBind();

    }

I have this exception after this code:

Input string was not in a correct format.

halfer
  • 19,824
  • 17
  • 99
  • 186
H.elsaidy
  • 1
  • 3
  • 2
    Possible duplicate of [Input string was not in a correct format](https://stackoverflow.com/questions/8321514/input-string-was-not-in-a-correct-format) – Claies Feb 09 '18 at 23:30
  • tl;dr the cell you are trying to read your `orderId` from doesn't contain a number. are you *sure* that you want `Cells[1]` (the second cell in the row)? – Claies Feb 09 '18 at 23:32
  • No i want the first cell which contains select statement – H.elsaidy Feb 09 '18 at 23:56
  • Arrays are zero based, which means the first item is 0, the second item is 1, etc. – Claies Feb 09 '18 at 23:57
  • i'ts a gridView should we deal with it as an array? – H.elsaidy Feb 09 '18 at 23:59
  • well, `Cells` is an array of `Cell` objects in the `SelectedRow`, right? – Claies Feb 10 '18 at 00:01
  • if you aren't sure, put a breakpoint on the line where you are assigning your `orderId`, and inspect the value that you are getting back. it won't be a number. – Claies Feb 10 '18 at 00:04
  • Thanks for your support dear,the issue have been solved with you recommend solution.sorry for late reply. – H.elsaidy Feb 11 '18 at 01:47

0 Answers0