protected void dgCoaches_ItemCommand(object source, DataGridCommandEventArgs e) { Label lbl = (Label)e.Item.FindControl("lblid"); id = int.Parse(lbl.Text); ServiceReference1.Service1Client sv = new ServiceReference1.Service1Client(); ServiceReference1.get_Coach_By_ID_Result coaches = sv.Get_Coach_By_ID(id); // get train name string trainname = sv.get_Train_By_ID(int.Parse(coaches.Train_ID.ToString())).Train_Name; // show data ddlTrainName.SelectedValue = coaches.Train_ID.ToString(); ddlCoachesType.SelectedItem.Text = coaches.Coach_Type; txtSeats.Text = coaches.Number_Of_Seats.ToString(); _train_id = int.Parse(coaches.Train_ID.ToString()); txtPrices.Text = coaches.Price.ToString(); if (coaches.Status.ToString() == "Active") { RadioButton1.Checked = true; RadioButton2.Checked = false; } else { RadioButton2.Checked = true; RadioButton1.Checked = false; } ddlTrainName.Enabled = false; ddlCoachesType.Enabled = false; btnUpdate.Visible = true; btnDelete.Visible = true; btnCancel.Visible = true; btnAdd.Visible = false; }