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

RadGrid Edit Disable on condition

3 Answers 687 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tan
Top achievements
Rank 1
Tan asked on 12 Apr 2012, 11:58 AM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 12 Apr 2012, 01:04 PM
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.
0
Naree
Top achievements
Rank 1
answered on 13 May 2014, 02:09 PM
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
0
Shinu
Top achievements
Rank 2
answered on 14 May 2014, 03:57 AM
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
Tags
Grid
Asked by
Tan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Naree
Top achievements
Rank 1
Share this question
or