Solved

events in gridview

Posted on 2016-08-25
2
28 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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 …
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

14 Experts available now in Live!

Get 1:1 Help Now