Solved

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

Posted on 2013-01-25
7
209 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
  • 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now