473,394 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Gridview text box column loses value after changing .Visible property

Hi,
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
forth.

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
blank.
EnableViewState is set to True for the form, Gridview and text box.

Got any suggestions?

Thanks,
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"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Use" InsertVisible="False">
<EditItemTemplate>
&nbsp;
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelected" runat="server"
AutoPostBack="True" CausesValidation="True"
OnCheckedChanged="chkSelected_CheckedChanged" /
>
</ItemTemplate>
</asp:TemplateField>
<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:BoundField>
<asp:TemplateField HeaderText="Qty Returnable">
<EditItemTemplate>
<asp:TextBox ID="txtQtyToRA" runat="server" Text='<
%# Eval("QtyToRA") %>' Width="40px"></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="20px" />
<ItemTemplate>
<asp:TextBox ID="txtQtyToRA" runat="server"
MaxLength="4" Text='<%# Eval("QtyToRA") %>'
Width="40px"></asp:TextBox>
<asp:RangeValidator ID="rgvQtyToRA" runat="server"
ControlToValidate="txtQtyToRA"
MinimumValue="0" MaximumValue='<%#
Eval("QtyShipped") %>' Type="Integer" Display="Dynamic"></
asp:RangeValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ShipFrom" HeaderText="Ship
From" ReadOnly="True" />
<asp:TemplateField HeaderText="Return Reason">
<ItemTemplate>
<asp:DropDownList ID="cboRAReason" runat="server"
Width="170px">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerTemplate>
not this way<br />
<br />
</PagerTemplate>
<AlternatingRowStyle BackColor="#FFFFC0" />
</asp:GridView>
Here's the event handler:
Protected Sub chkSelected_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs)
' Check status of ctonrols
CheckControlStatus()
gvItems.Columns(6).Visible = Not gvItems.Columns(6).Visible
End Sub

Feb 5 '07 #1
0 2392

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
1
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes...
2
by: kevinpond | last post by:
I have a Gridview displaying the results of a stored procedure. The stored procedure is constantly changing so the columns displayed in the data grid are constantly changing. I'd like to give...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
8
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i have a GridView and a hidden field : <asp:TemplateField Visible=false > <ItemTemplate > <asp:HiddenField Value="<%#Eval("isActive")%>" id="hidIsActive" runat=server /> </ItemTemplate>...
3
by: gnewsgroup | last post by:
I have a GridView which is bound to my database. The leftmost column of the GridView has a value of either 0 or 1, and I need to highlight the cell of column 3 if the leftmost column has a...
2
by: DC | last post by:
Hi, I am using a GridView to present data in a DataTable, which I store only in ViewState and when the user hits the "OK" button the rows in the DataTable will be used to execute transactions. ...
4
by: Jonathan Wood | last post by:
Greetings, I have a GridView control. For a couple of reasons, I ended up with a TemplateField to contain my Edit and Delete links, something like this: <asp:TemplateField ShowHeader="False">...
1
nitindel
by: nitindel | last post by:
Hi All, Please tell me any good site for Gridview control.(not for datagrid). I am facing error in fetching the values of the Bound columns in the gridview: lease tell me how should i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.