Solved

events in gridview

Posted on 2016-08-25
2
44 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

617 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