Solved

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

Posted on 2013-01-25
7
208 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:purplesoup
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Closing Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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!
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

10 Experts available now in Live!

Get 1:1 Help Now