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

Add a buttonColumn only for few lines of RadGrid

2 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Caro
Top achievements
Rank 1
Caro asked on 12 Jun 2012, 01:54 PM
Hi all :)

I'd like to add a buttonColumn only for few lines of my radgrid.
For example, it could be the lines where one of my database field has is value to "true"
I don't know how to make that.

Thx

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Jun 2012, 02:56 PM
Hi Caro,

One suggestion is to make the visiblity of the added ButtonColumn according to the data in database.

ASPX:
.  .  .
<telerik:GridBoundColumn UniqueName="Discontinued" DataField="Discontinued" HeaderText="Discontinued"></telerik:GridBoundColumn>
<telerik:GridButtonColumn UniqueName="ProductID" DataTextField="ProductID" HeaderText="ProductID" Visible="true"></telerik:GridButtonColumn>
.  .  .

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem ditem = (GridDataItem)e.Item;
        if (ditem["DisContinued"].Text == "True")
        {
            ditem["ProductID"].Visible = true;
        }
        else
        {
            ditem["ProductID"].Visible = false;
        }
    }
}

Thanks,
Shinu
0
Caro
Top achievements
Rank 1
answered on 14 Jun 2012, 12:02 PM
Thanks Shinu, It's perfect :)
Tags
Grid
Asked by
Caro
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Caro
Top achievements
Rank 1
Share this question
or