471,874 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,874 software developers and data experts.

Gridview text box column loses value after changing .Visible property

here's my problem in short: Text boxes in gridview don't seem to hold
their value if the column's .Visible property is changed back and

I've got a form with a gridview populated from a data view (which in
turn is loaded from a manually setup DataTable for testing purposes).
One of the columns in the grid is a checkbox that's tied to an event
handler that'll change the .Visible property of a column with a text
box. That text box column (column 6 in the example code below)
initially has a numeric value, but after hiding and showing again is
EnableViewState is set to True for the form, Gridview and text box.

Got any suggestions?

Joe Landes

ASP code to setup the control:
<asp:GridView ID="gvItems" runat="server" Height="59px"
Width="662px" Style="left: 17px;
position: relative; top: -1px" AllowSorting="True"
<asp:TemplateField HeaderText="Use" InsertVisible="False">
<asp:CheckBox ID="chkSelected" runat="server"
AutoPostBack="True" CausesValidation="True"
OnCheckedChanged="chkSelected_CheckedChanged" /
<asp:HyperLinkField HeaderText="Order #"
DataTextField="OrderNum" NavigateUrl="~/Login.aspx" />
<asp:BoundField DataField="OrderID" HeaderText="OEM #"
ReadOnly="True" />
<asp:BoundField DataField="UnitPrice"
DataFormatString="${0:C2}" HeaderText="Price"
ReadOnly="True" HtmlEncode="False" />
<asp:BoundField DataField="UnitCost"
DataFormatString="{0:c2}" HeaderText="Cost"
HtmlEncode="False" />
<asp:BoundField DataField="QtyShipped" HeaderText="Qty
Shipped" ReadOnly="True">
<ControlStyle Width="20px" />
<asp:TemplateField HeaderText="Qty Returnable">
<asp:TextBox ID="txtQtyToRA" runat="server" Text='<
%# Eval("QtyToRA") %>' Width="40px"></asp:TextBox>
<ControlStyle Width="20px" />
<asp:TextBox ID="txtQtyToRA" runat="server"
MaxLength="4" Text='<%# Eval("QtyToRA") %>'
<asp:RangeValidator ID="rgvQtyToRA" runat="server"
MinimumValue="0" MaximumValue='<%#
Eval("QtyShipped") %>' Type="Integer" Display="Dynamic"></
<asp:BoundField DataField="ShipFrom" HeaderText="Ship
From" ReadOnly="True" />
<asp:TemplateField HeaderText="Return Reason">
<asp:DropDownList ID="cboRAReason" runat="server"
not this way<br />
<br />
<AlternatingRowStyle BackColor="#FFFFC0" />
Here's the event handler:
Protected Sub chkSelected_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs)
' Check status of ctonrols
gvItems.Columns(6).Visible = Not gvItems.Columns(6).Visible
End Sub

Feb 5 '07 #1
0 2282

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by =?Utf-8?B?QmFidU1hbg==?= | last post: by
8 posts views Thread by =?Utf-8?B?cGVsZWdrMQ==?= | last post: by
3 posts views Thread by gnewsgroup | last post: by
4 posts views Thread by Jonathan Wood | last post: by
1 post views Thread by nitindel | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.