Solved

events in gridview

Posted on 2016-08-25
2
23 Views
Last Modified: 2016-09-13
When to use OnRowCreated event and when to use RowDataBound event???...........as we know that OnrowCreated event fires when the html-controls for a row are created....and RowDataBound event fires when the data row is bound to the data of the GridView. So please specified that in which condition we prefer one of them????????
0
Comment
Question by:abdullah bajwa
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points (awarded by participants)
ID: 41770048
RowCreated occurs after a row and all of its child controls are created.

RowDataBound occurs after the row (and its controls) are databound, i.e. populated with the data values.

The answer about which to use really depends on if you need the databound values or not.
e.g. If you wanted to change the background color of your row based the value of one of your fields, then you would have to use the RowDataBound event. If your logic doesn't depend on the data, then I don't think it matters which event you use.

An example of where you would have to use RowCreated is if you had a drop down list in your row that would need to be popluated with values before the selected value was databound.

RowCreated is focused on parsing Gridview row's definition and creating the Gridview row's control structure,

RowDataBound is focused on bind data to the row's controls created in the RowCreated.

Also RowCreated is invoked automatically in both init and postback case, but RowDataBound is only invoke when the DataBind is called.

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcreated.aspx
https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 41795684
Question is inactive for long and according to me this is the correct answer.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now