RadGrid Edit Disable on condition

4 posts, 1 answers
  1. Tan
    Tan avatar
    23 posts
    Member since:
    Jan 2012

    Posted 12 Apr 2012 Link to this post

    To,

    The problem is cannot make edit button disable certain row on match condition


    The example i use. that make all edit button hidden when one condition is match
            protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
            {
                    if (e.Item is GridDataItem) 
                    
                        GridDataItem item = (GridDataItem)e.Item;
     
                        GridButtonColumn gbtnCol = item.OwnerTableView.Columns.FindByUniqueName("column") as GridButtonColumn; 
                                gbtnCol.Text = "Resume"
                                gbtnCol.DataTextFormatString = "Resume"
                        GridEditCommandColumn gbtnCol2 = item.OwnerTableView.Columns.FindByUniqueName("EditCommandColumn") as GridEditCommandColumn;
                        Label txtProcessStatus = e.Item.FindControl("ProcessStatusLabel") as Label;
                         
                        //ProcessStatusTextBox gbtnCol3 = item.OwnerTableView.Columns.FindByUniqueName("ProcessStatus") as ProcessStatusTextBox;
     
                        if (gbtnCol2 != null )
                            if (txtProcessStatus.Text != "98")
                            {
                                gbtnCol2.Visible = false;
                                gbtnCol.Visible = false;
                                txtProcessStatus.Text = "11";
                            }
                         
                    }
    }



    Anyone have idea to disable Radgrid edit on certain row? Thanks advance.
    From louisth
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Apr 2012 Link to this post

    Hi Tan,

    Please try the following approach.

    C#:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
          {
             if (e.Item is GridDataItem)
             {
               GridDataItem item = (GridDataItem)e.Item;
               Label txtProcessStatus = e.Item.FindControl("ProcessStatusLabel") as Label;
               if (txtProcessStatus.Text != "98")
               {
                 ImageButton img = (ImageButton)item["EditCommandColumn"].Controls[0]; //Accessing EditCommandColumn
                 img.Visible = false;
               }                  
           }

    Please elaborate your scenario if it doesn't help.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Naree
    Naree avatar
    10 posts
    Member since:
    Apr 2014

    Posted 13 May 2014 in reply to Shinu Link to this post

    Hi Shinu,
     can u please explain the code what ever your posted above. I totally kinda new to c# . so i'm confusion about,


     Label txtProcessStatus = e.Item.FindControl("ProcessStatusLabel") as Label;




    Thanks in advance
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 May 2014 in reply to Naree Link to this post

    Hi Garivi,

    You can read through this article on Accessing Cells and Rows which explains in detail how to access the cells and rows of a RadGrid. If you have any concern, let me know.

    Thanks,
    Shinu
Back to Top