• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

System.Web.UI.WebControls.DataGrid data is lost if more than 3 rows are submitted

I have a data grid with a number of columns for the user to fill in. If they fill in up to three rows of the grid, the data comes over to the server and everything is fine.

If more than three rows are entered, although it appears that the data is present in the Request object, the DataGrid itself reports no rows.

What might be the cause of this and how can I fix it so there isn't this 3 row limitation?

Just to be clear, I logged Request.Form.ToString()) and I can see the grid data in the log, but if I check grid.Item there is no data, grid.Item.Count returns 0.
0
purplesoup
Asked:
purplesoup
  • 5
  • 2
1 Solution
 
guru_samiCommented:
1: If there is any loop check it's not somehow limited to 3 iterations only
2: Check if it's something in the data of your 4th row that might be causing to break.
3: Any databinding issues

Can you post some code?
0
 
purplesoupAuthor Commented:
There is a lot of code - it would probably take at least two days to try to extract out a self-supporting example, however I can add:

1. I did a search of the code for any uses of "3" or "4" to see if there is anything special about the third row - couldn't see anything.

2. The data is actually being sent back to the server - if I look in Request.Form I can see it all there, and in theory can access it through Request.Form[..] etc - it just isn't showing in the DataGrid object.

3. The grid itself contains some lookup links - you can either enter the ID of a contact directly if you know it, or lookup the id through clicking a link in the grid, a dialog will open allowing a search to be performed and the id returned back to the grid again. The problem only happens with this search dialog, but again only after 3 rows, it is ok using the search dialog and only populating three rows.

It must be something to do with losing data binding.

The grid is initially populated with some pre-set values in response to a "generate rows" button - an array of objects is generated and the grid bound to the array - this appears to work ok and the populated grid displays on the page. There is no other databinding done.
0
 
guru_samiCommented:
I don't have any other idea as I think I am not getting the clear picture of the issue.
Any way I can see this in action? or some screenshots might help...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
purplesoupAuthor Commented:
The probably must qualify as one of the strangest bugs I've come across. The web page itself is quite large - there are about a dozen controls which are used to pre-populate a similar number of columns in the System.Web.UI.WebControls.DataGrid.

One of the grid columns - for a contact - has a lookup page to search for the contact ID. Now here is the bizarre thing, I have stripped this down to a single asp:button that just calls an empty c# method on the server, that is all it does. If I click five times on the lookup, clicking the button each time, something messes up the DataGrid and when it gets to the server it says there are no rows (although Request.Form shows the data there).

I have removed all code that gets run after the dialog is called, so after opening it, I still have to type in the contact ID on the grid itself, so there literally is no interaction between the lookup page and the main grid - nothing is getting set or returned.

If I just click four times it works, but five clicks gets the problem. I've had to go onto some other work as this was taking too long, but that is where I am with it. I may come back to it later.
0
 
purplesoupAuthor Commented:
ok here is the answer. We were using SessionStatePagePersister to persist ViewState in the Session. If I changed the configuration to stop it doing that and just use ViewState normally in the browser... it worked.
0
 
purplesoupAuthor Commented:
0
 
purplesoupAuthor Commented:
It was really obscure - who knows why that fixes it, but it does and it might be useful to someone.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now