Advertisement
DevUModerator

Untitled

Jul 4th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. var cars = new List<Car>() {
  2. new Car { CarId=Guid.NewGuid(), Make="BMW", Model="528i", Year=2010 },
  3. new Car {CarId=Guid.NewGuid(), Make="Toyota", Model="4Runner", Year=2010},
  4. new Car {CarId=Guid.NewGuid(), Make="Hyundai", Model="Elantra", Year=2013}
  5. };
  6.  
  7. GridView1.DataSource = cars;
  8. GridView1.DataBind();
  9.  
  10. }
  11.  
  12. protected void GridView1_RowCommand( object sender, GridViewCommandEventArgs e )
  13. {
  14.  
  15. int index = Convert.ToInt32(e.CommandArgument);
  16. GridViewRow row = GridView1.Rows[index];
  17.  
  18. //This is a bit risky take great caution
  19. var make = row.Cells[1].Text;
  20. var model = row.Cells[2].Text;
  21. var value = row.Cells[4].Text;
  22.  
  23. //You probably want to convert to its original type
  24. var carId = Guid.Parse(value);
  25.  
  26. resultLabel.Text = String.Format("{0} {1} {2}",
  27. make,
  28. model,
  29. carId);
  30.  
  31.  
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement