Solved

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

Posted on 2013-01-25
7
212 Views
Last Modified: 2013-02-19
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
Comment
Question by:purplesoup
[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
  • 5
  • 2
7 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 38819388
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
 

Author Comment

by:purplesoup
ID: 38825973
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
 
LVL 41

Expert Comment

by:guru_sami
ID: 38827658
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:purplesoup
ID: 38840104
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
 

Accepted Solution

by:
purplesoup earned 0 total points
ID: 38889549
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
 

Author Comment

by:purplesoup
ID: 38893366
0
 

Author Closing Comment

by:purplesoup
ID: 38904746
It was really obscure - who knows why that fixes it, but it does and it might be useful to someone.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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