Gridview why all visible rows are set to dirty?

The code you have posted looks fine. My test code is almost identical to yours, but I cannot produce the unwanted results you are seeing The most significant difference between your code and mine is that I don't have the code for your master page. My master page is the default page created by VS 2008.

Other than that, the differences are in the SQL and the underlying database. Specifically, I am not using any stored procedures, and I have made reasonable assumptions about the data types involved: the ID is int Status is smallint SheetDate is Date DateUpdated is DateTime and everything else is varchar EDIT: Your SheetDate appears to be just the date portion of an underlying DateTime value from the database. The fact that your query transforms the underlying data value for display purposes is not relevant, because the grid view can't tell that it is getting a modified value END OF EDIT Here are a few suggestions for diagnosing the problem: Test without master page, or with a very simple dummy master page that is guaranteed not to have scripts that interact with the BulkEditGridView Since the ToolkitScriptManager is apparently on your master page, you will need to either move the script manager control to the page itself, or else temporarily get rid of the CalendarExtender element, which requires the script manager Temporarily replace the Status template field with a bound data field, to eliminate possibility of interaction with the DropDownList The drop down list did not cause problems in my tests, but there may be subtle differences between your code and mine If neither of these help, then a possible cause is a problem in your version of the BulkEditGridView EDIT - Additional suggestions for diagnosis: Based on examination of the source code for BulkEditGridView it appears that the code is properly tracking which rows of the grid are "dirty".

Therefore, the most likely cause of a spurious dirty row is that one or more controls in the grid are incorrectly detecting a change to their data content. You can detect this in the debugger, using the source code for BulkEditGridView rather than the pre-compiled DLL Set a breakpoint at the start of HandleRowChanged the event handler which detects changes in any cell of the grid. By examining the sender parameter of that object in the debugger, you can tell which controls in the grid are undergoing value changes.In particular, you will be able to tell which controls, if any, are incorrectly triggering a value change event Once you determine which control(s) are incorrectly reporting that their value has changed, you can focus on why this is happening END OF EDIT Some other suggestions to improve the code are as follows These will not solve the original problem but will make the code cleaner: In all of the template fields, remove the ItemTemplate s.

They can never be used, since the BulkEditGridView forces every row to be in the edit state In the code behind, the BindData() call is not needed, since the source data is specified in the declarative markup, and therefore the grid view control will automatically bind the data.

The code you have posted looks fine. My test code is almost identical to yours, but I cannot produce the unwanted results you are seeing. The most significant difference between your code and mine is that I don't have the code for your master URL1 master page is the default page created by VS 2008.

Other than that, the differences are in the SQL and the underlying database. Specifically, I am not using any stored procedures, and I have made reasonable assumptions about the data types involved: the ID is int, Status is smallint, SheetDate is Date, DateUpdated is DateTime, and everything else is varchar. EDIT: Your SheetDate appears to be just the date portion of an underlying DateTime value from the database.

The fact that your query transforms the underlying data value for display purposes is not relevant, because the grid view can't tell that it is getting a modified value. END OF EDIT Here are a few suggestions for diagnosing the problem: Test without master page, or with a very simple dummy master page that is guaranteed not to have scripts that interact with the BulkEditGridView. Since the ToolkitScriptManager is apparently on your master page, you will need to either move the script manager control to the page itself, or else temporarily get rid of the CalendarExtender element, which requires the script manager.

Temporarily replace the Status template field with a bound data field, to eliminate possibility of interaction with the DropDownList. The drop down list did not cause problems in my tests, but there may be subtle differences between your code and mine. If neither of these help, then a possible cause is a problem in your version of the BulkEditGridView.

EDIT - Additional suggestions for diagnosis: Based on examination of the source code for BulkEditGridView, it appears that the code is properly tracking which rows of the grid are "dirty". Therefore, the most likely cause of a spurious dirty row is that one or more controls in the grid are incorrectly detecting a change to their data content. You can detect this in the debugger, using the source code for BulkEditGridView, rather than the pre-compiled DLL.

Set a breakpoint at the start of HandleRowChanged, the event handler which detects changes in any cell of the grid. By examining the sender parameter of that object in the debugger, you can tell which controls in the grid are undergoing value changes.In particular, you will be able to tell which controls, if any, are incorrectly triggering a value change event. Once you determine which control(s) are incorrectly reporting that their value has changed, you can focus on why this is happening.

END OF EDIT Some other suggestions to improve the code are as follows. These will not solve the original problem, but will make the code cleaner: In all of the template fields, remove the ItemTemplates. They can never be used, since the BulkEditGridView forces every row to be in the edit state.

In the code behind, the BindData() call is not needed, since the source data is specified in the declarative markup, and therefore the grid view control will automatically bind the data.

I can try it without, but I believe I put that databind() in there while trying to make the sorting and paging work. Also, the Item Templates are probably not needed. I just let them autogenerate at first, then I changed things.

– MAW74656 May 5 at 19:32 1 @MAW - Databind shouldn't be needed for sorting and paging, since that requires postback, so your Databind code wouldn't execute then anyway. I kind of thought the item templates were autogenerated. It wasn't obvious to me that they weren't needed until I looked at the BEGV source code.

– Joel Lee May 5 at 19:58 SheetDate is actually a datetime which I'm using a user defined sql function to truncate into just a date. I tried replacing the RealWorldGridView dll, no dice. I also tried adding a scriptmanagerproxy onto the content page, no dice.

– MAW74656 May 6 at 19:00 1 You will have to use the source code, not the precompiled dll. There are a couple of ways to do that. – Joel Lee May 6 at 20:51 1 I am at a loss, since I cannot duplicate this.

See if the code works if you just return sheetDate in your query, without calling dbo.dateOnly. I have tried my code with a full DateTime value here, and it works fine. I can't see how truncating the date would make any difference whatsoever, but it is the only significant difference between my code and yours.

I'll try to check for a response at lunch time. – Joel Lee May 11 at 4:43.

I am not an expert in BulkEditGridView control, but this is what I found at Matt Dotson's blog entry You may not be able to know that the row has been updated, unless you watch for the change explicitly. First, for each row add a change handler protected override void InitializeRow(GridViewRow row, DataControlField fields) { base. InitializeRow(row, fields); foreach (DataControlFieldCell cell in row.

Cells) { if (cell.Controls. Count > 0) { AddChangedHandlers(cell. Controls); } } } You can use this snippet private void AddChangedHandlers(ControlCollection controls) { foreach (Control ctrl in controls) { if (ctrl is TextBox) { ((TextBox)ctrl).

TextChanged += new EventHandler(this. HandleRowChanged); } else if (ctrl is CheckBox) { ((CheckBox)ctrl). CheckedChanged += new EventHandler(this.

HandleRowChanged); } else if (ctrl is DropDownList) { ((DropDownList)ctrl). SelectedIndexChanged += new EventHandler(this. HandleRowChanged); } } } Then you define a dirty row list and add rows that needs to be updated there (in the event handler) private List dirtyRows = new List(); void HandleRowChanged(object sender, EventArgs args) { GridViewRow row = ((Control) sender).

NamingContainer as GridViewRow; if (null! = row &&!dirtyRows. Contains(row.

RowIndex)) { dirtyRows. Add(row. RowIndex); } } Finally, to commit changes, iterate through all the dirty rows and save changes public void Save() { foreach (int row in dirtyRows) { this.

UpdateRow(row, false); } dirtyRows.Clear(); } And here is your ASPX code.

I saw that, but looking at the source code of the control, that's all built into the control. The give-aways are the use of this. , base.

, and override. This is part of what's confusing me. – MAW74656 May 2 at 19:27 This seems to be the code of the BulkEditGridView control itself, so theoretically you just need to call just Save method.

I can't see in your code that you actually called Save, have you? – oleksii May 2 at 19:42 s article says that isn't needed. He's very proud of providing a good developer experience.

I'll see if it makes any difference. – MAW74656 May 2 at 20:27 No effect with an explicit call to Save(); – MAW74656 May 2 at 20:34 @MAW74656 - You are correct. Save() is called internally by the control when the Save button is clicked.

Clicking it again won't do anything, because the save method clears the dirtyRows list (see code above in this answer). – Joel Lee May 2 at 21:05.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions