15,898,010 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by .Net Jim (Top 1 by date)
.Net Jim
8-Jan-15 14:59pm
View
OK. Something else has come to my attention. You are mixing things up and this is why things are firing multiple times.
ViewState is a cache for the entire web page. It is not advisable to tap into it from a multiple event situation like rowdatabound. You should tap into your rows of data by grabbing data from sender. Sender is a copy of the control creating the event, and the args are the settings for the object, not the data.
Follow how you see it done here, making sure to search for your control, then set the value. Also, this works much better if you set some column templates with names for the controls.
I will try to find a youtube tutorial later, but this article will give you plenty of code to tap into your grid from sender object. Viewstate should only be done once or twice on page from event that only fires once or twice during page load sequence of events, maybe from button click. Rowdatabound is called with every row of your grid, so performance will slow down also.
http://www.codeproject.com/Answers/305101/Set-Eval-in-Code-Behind#answer2