protected void MenuItemGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "AddItem") { int index = Convert.ToInt32(e.CommandArgument); int menuItemId = Convert.ToInt32(MenuItemGridView.Rows[index].Cells[0].Text); WcfServiceReference.MenuItem menuItem = entities.MenuItems.Where(x => x.Id == menuItemId).FirstOrDefault(); Master.AddItem(menuItem); } }