473,549 Members | 2,982 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 2408

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

Similar topics

1
3852
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. ...
1
9338
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
2211
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...
4
7221
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...
8
18801
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...
3
15708
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()...
2
3239
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...
4
1793
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>...
1
1838
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
7518
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...
1
7469
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...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
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...
0
5087
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...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
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
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
757
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...

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.