Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var cars = new List<Car>() {
- new Car { CarId=Guid.NewGuid(), Make="BMW", Model="528i", Year=2010 },
- new Car {CarId=Guid.NewGuid(), Make="Toyota", Model="4Runner", Year=2010},
- new Car {CarId=Guid.NewGuid(), Make="Hyundai", Model="Elantra", Year=2013}
- };
- GridView1.DataSource = cars;
- GridView1.DataBind();
- }
- protected void GridView1_RowCommand( object sender, GridViewCommandEventArgs e )
- {
- int index = Convert.ToInt32(e.CommandArgument);
- GridViewRow row = GridView1.Rows[index];
- //This is a bit risky take great caution
- var make = row.Cells[1].Text;
- var model = row.Cells[2].Text;
- var value = row.Cells[4].Text;
- //You probably want to convert to its original type
- var carId = Guid.Parse(value);
- resultLabel.Text = String.Format("{0} {1} {2}",
- make,
- model,
- carId);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement