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

[Solved] finding GridButtonColumn at run time

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amarinder Singh
Top achievements
Rank 1
Amarinder Singh asked on 27 Jan 2010, 01:10 PM
Hello 

       I am struck with another problem. I am using  

<

 

telerik:GridButtonColumn FooterText="" DataTextFormatString="Approve"

 

 

 

UniqueName="approve" HeaderText="Approve" CommandName="MyCommandName" CommandArgument="" DataTextField="id">

 

 

 

<ItemStyle Width="100px" />

 

 

 

</telerik:GridButtonColumn>

On some condition i want to make this approve link disable and enable on  run time. How we can get this at link run time and on which event we can enable and disable this link. 

 

 

Thanks
Amarinder

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Jan 2010, 02:09 PM
Hi Amarinder,

You can check for condition in ItemDataBound event as shown below and set the Enabled property of the LinkButton after accessing it.

CS:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)   
    {   
        if (e.Item is GridDataItem)   
        {   
            GridDataItem item = (GridDataItem)e.Item;   
            if (condition) // Check for condition 
            {   
                ((LinkButton)item["approve"].Controls[0]).Enabled = false;   
            } 
            else 
            { 
                ((LinkButton)item["approve"].Controls[0]).Enabled = true;   
            } 
        }   
    } 

-Shinu.
Tags
Grid
Asked by
Amarinder Singh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or