Hi I was just wondering what is the best way to fetch gridview data using row databound event of gridview. I am previously used to Eval but read its not recommended as it uses reflection.
What do you mean "Fetch" the data, by the time the the RowDataBound event has triggered, there already has to be a row of data, that is why the event has executed. If you want to access and mapipulate the data then it is in e.Row.DataItem
.
Edit
To answer your comment, using Eval in the markup and putting code in the RowDataBound event handler and accessing e.Row.DataItem
tend to be used under different cirumstances. If all you want to do is take the data and bind it to the property of a control then using Eval() (or Bind() for that matter) is fine. However if you want to do something more complex then you might need to do it in the RowDataBound event handler. For exam-ple you might have a grid of customer accounts and ballances. For customers where thir ballances are overdue you might want to turn the row red to highlight the fact that thier accounts are overdue. You could not do that using Eval or Bind in the markup so you would check e.Row.DataItem
in the RowDataBound event handler and then decide whether to change the colour of the row.