Last post Oct 10, 2016 03:02 AM by Deepak Panchal
Oct 07, 2016 01:21 PM|saurav gautam|LINK
There is a gridview on my aspx page. The gridview data are obtained from XMLDataSource.
The third column of my gridview will contain image path. I will be using the path to display image on image-button.
img = GridView1.SelectedRow.Cells.ToString();
ImageButton1.ImageUrl = img;
If I put the above codes on page-load event, I receive following error
Object reference not set to an instance of an object.
Which means the gridview data haven't been loaded. What event can I use so that the codes can be run immediately after the data are loaded on the gridview.?
Oct 07, 2016 02:13 PM|mazhar khan india|LINK
Can you show your code. Or check below link will help.
Oct 10, 2016 03:02 AM|Deepak Panchal|LINK
if you are putting the code on load event and if your grid view is not loaded then you receive an error.
so what you need to do is load the grid view before Load event.
so that when your above mentioned code execute on load event then it get the data available in the grid view.
(1) preinit (2) Init (3) initcomplete (4) PreLoad
These 4 events called before load event.
so you can use these events to load the grid view.
you can view the Asp.Net page life cycle events mentioned in the link below. so that you can get detailed information regarding events.
Here I think you should try to use PreLoad Event.