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

4 posts, 0 answers
  1. Mohamed El-Sayed
    Mohamed El-Sayed avatar
    33 posts
    Member since:
    Apr 2009

    Posted 14 Mar 2013 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Mar 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mohamed El-Sayed
    Mohamed El-Sayed avatar
    33 posts
    Member since:
    Apr 2009

    Posted 14 Mar 2013 Link to this post

    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
  5. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 19 Mar 2013 Link to this post

    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.
Back to Top