Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

events in gridview

Posted on 2016-08-25
2
Medium Priority
?
51 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Integration Management Part 2
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

885 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