C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET GridView »

If condition with inline code


Posted Date: 17 Oct 2008    Resource Type: Code Snippets    Category: ASP.NET GridView
Author: Alok Kumar MohantyMember Level: Silver    
Rating: 1 out of 5Points: 7



Let say I have a gridView in my asp.net page. I am binding the gridview with some data. I want to check some condition for a particular column while binding the data to the gridview. Then we can use the following inline code to check the condition:

Text='<%# DataBinder.Eval(Container.DataItem,"dname").ToString()=="S. Mallick"?"Alok":DataBinder.Eval(Container.DataItem,"dname") %>'

Where I am binding the text property of a label in a template field of a gridview.
I am testing if the column 'dname' has the value 'S.Mallick' then it will bin the column with the value 'Alok'.



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
If condition with inline code  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Custom Paging using Object Data Source
Previous Resource: Code for checked changed event of checkbox in gridview
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET GridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use