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

In press in edit button want to check if drop doen list contain value or n't

3 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohamed El-Sayed
Top achievements
Rank 1
Mohamed El-Sayed asked on 14 Mar 2013, 09:42 AM
Hi ,
i've a drop down list in the edit mode, i just want to check while i prees in the edit button if the drop down list have value " Confirmed " and " N't Confirmed " if it have anyone from the two values , don't open edit and give him message that's already edited

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Mar 2013, 11:49 AM
Hi,

I am not sure about your requirement. I guess you are using the asp.DropDownlist to show the Confirmation status. Here is the code I tried to check whether the DropDownList item contains 'Confirm' or NotConfirm'.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
     if(e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         GridEditableItem Item = (GridEditableItem)e.Item;
         DropDownList DropDownList1 = (DropDownList)Item.FindControl("DropDownList1");//accessing the DropDownList
         foreach (ListItem item in DropDownList1.Items)
         {
             if ((item.ToString().Equals("Confirm")) ||(item.ToString().Equals("NotConfirm")) )
             {
                 Page.ClientScript.RegisterStartupScript(this.GetType(), "click", "alert('Cannot Edit');", true);
                 e.Item.Edit = false
             }
         }
     }
}

Thanks,
Princy.
0
Mohamed El-Sayed
Top achievements
Rank 1
answered on 14 Mar 2013, 02:31 PM
thanks Princy it's worked , but after the alert message open and press close the edit pop up appear

how can i make it disappear
0
Kostadin
Telerik team
answered on 19 Mar 2013, 09:10 AM
Hi Mohamed,

Note that you have to hook on ItemCommand and cancel the edit command. Check out the following code snippet.
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.EditCommandName)
        {
            GridEditableItem item = (GridEditableItem)e.Item;
            DropDownList DropDownList1 = (DropDownList)Item.FindControl("DropDownList1");
            if ((item.ToString().Equals("Confirm")) ||(item.ToString().Equals("NotConfirm")) )
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "click", "alert('Cannot Edit');", true);
                e.Canceled = true;
            }
        }
    }


Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Mohamed El-Sayed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mohamed El-Sayed
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or