Bug 13122 - GridView hidden BoundFields retain data
Summary: GridView hidden BoundFields retain data
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-07-09 10:26 UTC by ryepup
Modified: 2013-07-09 10:29 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description ryepup 2013-07-09 10:26:47 UTC
This is a behavior difference between Mono and Microsoft. 

If you have a `GridView` with a hidden `BoundField`, the text contents of that cell are discarded in Microsoft, and retained in Mono.

I'm not sure the best way to describe this, here's a brief example, assuming the grid is bound to some data source:

----

	<asp:GridView runat="server" OnSelectedIndexChanged="OnChange" id="gv">
		<BoundField DataField="test" Visible="false"/>
		<BoundField DataField="test"/>
	</asp:GridView>

	<script runat="server">
	
	protected void OnChange(object sender, EventArgs e){
	    Debug.Assert(gv.SelectedRow.Cells[1].Text == "test", "Microsoft and Mono both see the visible cell");
	    Debug.Assert(gv.SelectedRow.Cells[0].Text == string.Empty, "on Microsoft the hidden cell is empty");
	    Debug.Assert(gv.SelectedRow.Cells[0].Text == "test", "on Mono the hidden cell has it's value");
	}
	</script>

----

Personally, I prefer Mono's current functionality, but my production server is running Microsoft .NET, so any behavior differences are bugs for me.

As further evidence of this "feature" of Microsoft's `BoundField`, here are some links to other people trying to work around this behavior in Microsoft to get something more like Mono's behavior:

 * http://stackoverflow.com/questions/11486372/retrieve-data-from-visible-false-boundfield-of-gridview
 * http://www.codeproject.com/Tips/80964/How-to-get-Hidden-Column-Value-in-GridView
Comment 1 ryepup 2013-07-09 10:29:45 UTC
This is running xsp2 vs .NET runtime 2.x and ASP.NET 2.x

Note You need to log in before you can comment on or make changes to this bug.