This is a migrated thread and some comments may be shown as answers.

Help: update in radgrid in line editing

0 Answers 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark de Torres
Top achievements
Rank 1
Mark de Torres asked on 08 Aug 2012, 08:17 AM
Hi guys,

I am trying to get the validation working. The validation is working fine but it does not prevent to stay in the current mode. Is there any way to lock the grid if the validation failed? (lock it to current mode (edit mode). Currently it is display the error message but it does not lock the grid. 

protected void ParticipationGrid_UpdateCommand(object sender, GridCommandEventArgs e)
    {
        RadDatePicker dpEndDate = new RadDatePicker();
        RadDatePicker dpStartDate = new RadDatePicker();
        RadComboBox cbReason = new RadComboBox();


        dpStartDate = (RadDatePicker)e.Item.FindControl("dtParticipationStartDate");
        dpEndDate = (RadDatePicker)e.Item.FindControl("dtParticipationEndDate");
        cbReason = (RadComboBox)e.Item.FindControl("ddlReasonLeaving");


      
        bool canUpdate = true;
       
        


        if (dpStartDate.SelectedDate < dtInstanceStartDate.SelectedDate)
        {
            message = "- Participation start date must be less than current instance start date";
            lblErrorParticipationDate.Text = message;
            lblErrorParticipationDate.Visible = true;
            canUpdate = false;
        }

        
        else
        {
            lblErrorParticipationDate.Visible = false;
            GridEditableItem editItem = (GridEditableItem)e.Item;
            string id = editItem.OwnerTableView.DataKeyValues[editItem.ItemIndex]["ParticipationID"].ToString();
            participationEntity = new ParticipationEntity(int.Parse(id));
            //participationEntity.ParticipationId = int.Parse(id);
            if (dpEndDate.SelectedDate != null && dpEndDate.SelectedDate > DateTime.MinValue)
            {
                participationEntity.ParticipationEnd = dpEndDate.SelectedDate;
                participationEntity.ReasonForLeavingId = int.Parse(cbReason.SelectedValue);
            }
            else if (dpEndDate.SelectedDate == null && cbReason.SelectedValue == "0")
            {
                participationEntity.ParticipationEnd = null;
                participationEntity.ReasonForLeavingId = null;
            }


            TextBox tbNotes = new TextBox();
            tbNotes = (TextBox)e.Item.FindControl("txtNotes");
            participationEntity.ParticipationNotes = tbNotes.Text;
            if (canUpdate)
            {
                SaveParticipation(sender, e);
            }


        }


    }

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Mark de Torres
Top achievements
Rank 1
Share this question
or