Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

events in gridview

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

670 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