Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good morning Experts,

Can a column in Gridview act differently based on conditions? Meaning, I want something like below

My last column should show a File if exists in Database as "Download" Link button" If not like a "Button" asking for "Do you want to attach a file"

Can we achieve something like this? If so please tell me how.
Posted
Updated 5-Mar-15 2:38am
v2
Comments
ZurdoDev 5-Mar-15 8:38am    
You can use the RowCreated or RowDataBound events to do stuff like this.
sudevsu 5-Mar-15 8:47am    
can you share any examples?

1 solution

As RyanDev Commented, you can use GridView RowDataBound event, for sample code, check below similar question and answer
GridView Conditional Button Visibility[^]
and also check the MSDN documentation of GridView.RowDataBound Event[^]
 
Share this answer
 
Comments
sudevsu 5-Mar-15 10:33am    
Alright may be my question is not properly framed. I am not looking for conditional visibility . I am looking for conditional Control change. Meaning, Based on condition control should behave like a linkbutton or it should behave like a browse button.
DamithSL 5-Mar-15 10:39am    
you can check the condition in the event and then change the Text to Browse or Link Text, on button onclick event you can do the redirect to given link or open file browse dialog box

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900