Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ItemCreated event on Datagrid PageIndexChanged

Status
Not open for further replies.

clanm

Programmer
Dec 26, 2005
237
US
My basic goal is to highlight a row if there's a certain data condition. This is fine, until the user tries to page to the next page, and I get the:
"Object not set to an instance of an object"

I went through the code, and if I comment out my ItemCreated even of the datagrid, I can page successfully.

Do I need to call something in my PageIndexChanged event so the ItemCreated event gets called as well?
Here's the pageindexchanged event:

DG.CurrentPageIndex = e.NewPageIndex
If txtWBSNumber.Text <> String.Empty Then
Call BuildDGFiltered()
Else
Call BuildDG()
End If

Thanks!
 
and I get the:
"Object not set to an instance of an object"
Which line of code does this happen on?



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
The ItemCreated event is line 221 through 251:

WP.ReviewExportPage.DG_ItemCreated(Object sender, DataGridItemEventArgs e) +98

System.Web.UI.WebControls.DataGrid.OnItemCreated(DataGridItemEventArgs e) +110

System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex, Int32 dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem, DataGridColumn[] columns, TableRowCollection rows, PagedDataSource pagedDataSource) +111

System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource) +1405
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +60
System.Web.UI.Control.EnsureChildControls() +100
System.Web.UI.WebControls.BaseDataList.get_Controls() +12
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +290
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +412
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +412
System.Web.UI.Page.LoadPageViewState() +306
System.Web.UI.Page.ProcessRequestMain() +447
 
I just moved all the code to the ItemDataBound event and it's working!
 
That doesn't really show much. Can you paste the full error details that you get?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top