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

[Solved] Make button invisible based on row contents

1 Answer 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Derek Maxwell
Top achievements
Rank 1
Derek Maxwell asked on 10 Nov 2009, 06:48 PM
Hello,

 I am looking for a way to make a button in an individual row visible/invisible based on the row contents.

For example:

Column1(Location Type) Column2(Location) Column3(Delete)
P                                       Airport                    <Delete Button>
S                                        Hotel                        <Delete Button>
D                                           Restaurant            <Delete Button>

If the Location Type is P or D, I want to make the delete button invisible. How can this be done?

Thank you,
Derek

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Nov 2009, 04:44 AM
Hi Derek,

Try the following code snippet in order to hide the autogenerated delete button based on row value.

C#:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            if (item["LocationType"].Text == "P" || item["LocationType"].Text == "D"
            { 
                LinkButton delButton = (LinkButton) item["AutoGeneratedDeletecolumn"].Controls[0]; 
                delButton.Visible = false
            } 
        } 
    } 

Regards,
Shinu.
Tags
Grid
Asked by
Derek Maxwell
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or