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

Avoid edit link in certain rows

2 Answers 24 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Savyo
Top achievements
Rank 1
Savyo asked on 25 Jun 2012, 01:44 PM
Hai,
     I have included edit command box in my grid. However i dont want the edit link in certain rows. How can I implement this. Can anybody help me
thank you in advance
Savyo

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jun 2012, 01:56 PM
Hi Savyo,

Try the following code to achieve your scenario.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
   if (e.Item is GridDataItem)
   {
     GridDataItem item = (GridDataItem)e.Item;
     if (item["UniqueName"].Text == "text")
     {
        LinkButton link= (LinkButton)item["AutoGeneratedEditColumn"].Controls[0]; //Accessing autogeneratededitcolumn    
        link.Visible = false;
     }   
   }
}

Thanks,
Shinu.
0
Casey
Top achievements
Rank 1
answered on 25 Jun 2012, 02:03 PM
Hi Savyo,

You can achieve this in the RadGrid's ItemDataBound event. I'm assuming you want the edit link to be hidden based on the value of another column in that row... if so, the below example should help!

Thanks!
Casey

****Edit**** I just saw Shinu's response. His will work if you are using the autogenetated edit column. My example would be for a GridTemplateColumn with an Edit linkbutton in the ItemTemplate. 

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem dataItem = e.Item as GridDataItem;
            LinkButton editLB = dataItem.FindControl("LinkButton1") as LinkButton;
 
            if (dataItem["YourColumnUniqueName"].Text == "SomeValue")
            {
                editLB.Visible = false;
            }
            else
            {
                editLB.Visible = true;
            }
        }
}
Tags
Grid
Asked by
Savyo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Casey
Top achievements
Rank 1
Share this question
or