473,881 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="T rue"
AutoGenerateCol umns="False">
<Columns>
<asp:TemplateFi eld HeaderText="Use " InsertVisible=" False">
<EditItemTempla te>
&nbsp;
</EditItemTemplat e>
<ItemTemplate >
<asp:CheckBox ID="chkSelected " runat="server"
AutoPostBack="T rue" CausesValidatio n="True"
OnCheckedChange d="chkSelected_ CheckedChanged" /
>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:HyperLinkF ield HeaderText="Ord er #"
DataTextField=" OrderNum" NavigateUrl="~/Login.aspx" />
<asp:BoundFie ld DataField="Orde rID" HeaderText="OEM #"
ReadOnly="True" />
<asp:BoundFie ld DataField="Unit Price"
DataFormatStrin g="${0:C2}" HeaderText="Pri ce"
ReadOnly="True" HtmlEncode="Fal se" />
<asp:BoundFie ld DataField="Unit Cost"
DataFormatStrin g="{0:c2}" HeaderText="Cos t"
HtmlEncode="Fal se" />
<asp:BoundFie ld DataField="QtyS hipped" HeaderText="Qty
Shipped" ReadOnly="True" >
<ControlStyle Width="20px" />
</asp:BoundField>
<asp:TemplateFi eld HeaderText="Qty Returnable">
<EditItemTempla te>
<asp:TextBox ID="txtQtyToRA " runat="server" Text='<
%# Eval("QtyToRA") %>' Width="40px"></asp:TextBox>
</EditItemTemplat e>
<ControlStyle Width="20px" />
<ItemTemplate >
<asp:TextBox ID="txtQtyToRA " runat="server"
MaxLength="4" Text='<%# Eval("QtyToRA") %>'
Width="40px"></asp:TextBox>
<asp:RangeValid ator ID="rgvQtyToRA " runat="server"
ControlToValida te="txtQtyToRA "
MinimumValue="0 " MaximumValue='< %#
Eval("QtyShippe d") %>' Type="Integer" Display="Dynami c"></
asp:RangeValida tor>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:BoundFie ld DataField="Ship From" HeaderText="Shi p
From" ReadOnly="True" />
<asp:TemplateFi eld HeaderText="Ret urn Reason">
<ItemTemplate >
<asp:DropDownLi st ID="cboRAReason " runat="server"
Width="170px">
</asp:DropDownLis t>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
<PagerTemplat e>
not this way<br />
<br />
</PagerTemplate>
<AlternatingRow Style BackColor="#FFF FC0" />
</asp:GridView>
Here's the event handler:
Protected Sub chkSelected_Che ckedChanged(ByV al sender As
System.Object, ByVal e As System.EventArg s)
' Check status of ctonrols
CheckControlSta tus()
gvItems.Columns (6).Visible = Not gvItems.Columns (6).Visible
End Sub

Feb 5 '07 #1
0 2444

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

Similar topics

1
3872
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 using a GridView that has ViewState enabled, an ObjectDataSource to process the submitted list, textboxes for getting new item data and an add button. Does this approach sound feasible or are there better alternatives? My problem is that I don't...
1
9363
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 GridView.Visible = True. I press HIDE and the GridView disappears as expected. After it I press SHOW and the GridView doesn't show.
2
2226
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 users the ability to filter by the value of any column. This is easily done using the FilterExpression property of the DataSource. However, prior to creating the filter expression, I need to know if the column they wish to filter contains text or...
4
7259
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 - "Modified" of type DateTime - is hidden since it should not be edited by a user. The system handles the update for this column. So, I have hidden (Visible=false) this column on the grid. In order to access the value in this field, I have created a...
8
18833
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> </asp:TemplateField> 1)when i check the sorce of html i dont see the hidden field - why is that? 2)on RowDataBound event, when i check the rows i want to check thr above field value,and to do something on certin conditions.
3
15723
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 value of 0. After highlighting, I want the leftmost column to disappear. So, in the OnDataBound event handler, I call a method HighlightCells() which looks like this (code from my memory):
2
3255
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. I need the ability to insert new rows (which is easily done with DataTable.Rows.Add(newRow) and rebinding) and then present a row with different TemplateFields for those rows (I need multiple rows in this insert state).
4
1817
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"> <EditItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton> &nbsp;<asp:LinkButton ID="LinkButton2" runat="server"
1
1856
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 fetch the value..of a bound column..?? Below is the code.:
0
9928
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10816
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9554
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7953
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7110
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4196
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.