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

I need to visible or disable some GridButtonColumn

4 Answers 761 Views
Grid
This is a migrated thread and some comments may be shown as answers.
chatchai
Top achievements
Rank 1
chatchai asked on 14 Mar 2011, 01:06 PM
i need to disable Gridbuttoncolumn where my value=0 if my value =1 Gridbuttoncolumn still show i try to use this code

For i = 0 To dt.Rows.Count - 1
          Dim dd As String = dt.Rows(i).Item("StatusCode").ToString
          If dd <> "0" Then
              RadGrid1.MasterTableView.Columns.FindByUniqueName("Accept").Visible = False
           End If
       Next

but if  dd <> 0  on the last of row button name "Accept" will be not show all of row

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 14 Mar 2011, 02:17 PM
Hello,

In order to set the visibility for the control , you need to access the control first and then set the visibility. Here is a sample code.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
 
        if (e.Item is GridDataItem)
        {
                GridDataItem item = (GridDataItem)e.Item;
                if (item["StatusCode"].Text == "1")//your condition
                {
                    LinkButton btn = (LinkButton)item["BtnCol"].Controls[0];
                    btn.Visible=false;
                }
        }
    }

aspx:
<telerik:GridBoundColumn DataField="StatusCode" HeaderText="StatusCode" UniqueName="StatusCode">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn UniqueName="BtnCol" HeaderText="ButtonCol" Text="Accept">
</telerik:GridButtonColumn>

Thanks,
Shinu.
0
chatchai
Top achievements
Rank 1
answered on 15 Mar 2011, 03:17 AM
Hello shinu
thank you for your reply
thank you very much again.
Ton 
0
Johannes van Rooyen
Top achievements
Rank 1
answered on 15 Jun 2011, 08:26 PM
GREAT POST! .. I have been wanting to do this for some time now, but was never able to make it work til now.

Thanks
0
Luis
Top achievements
Rank 1
answered on 28 Oct 2011, 07:19 PM
Thank you verymuch!
Tags
Grid
Asked by
chatchai
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
chatchai
Top achievements
Rank 1
Johannes van Rooyen
Top achievements
Rank 1
Luis
Top achievements
Rank 1
Share this question
or