473,408 Members | 1,739 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,408 software developers and data experts.

checkbox inside gridview

I'm trying to make visible or invisible a textbox depending on whether a
checkbox is clicked. Both controls are inside the same gridview. I've
tried program this in the CheckedChanged event but visual studio keeps
telling me the textbox control is not declared. Here's how the controls are
in gridview:

<edititemtemplate>
<asp:CheckBox checked='<%#Eval("chkfield")%>'
ID="chk1" runat="server" TextAlign="Left" AutoPostBack="true"
OnCheckedChanged="chk1_CheckedChanged" />
<asp:TextBox id="txt1" Text='<%#Eval("textfield") %>'
Width="30" MaxLength="1" runat="server" />
</edititemtemplate>

What should be the correct way of doing this? Does this has to be done in
one of those row-level event of the gridview? Appreciate any advice.
Nov 18 '08 #1
1 3762
Since the Checked property is databound, you need to run your code in the
RowDataBound event. The event is raised for every row, so you need to detect
the event raised for the row that is edited.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"E. Kwong" <ekwong999AThotmail.comwrote in message
news:e6**************@TK2MSFTNGP06.phx.gbl...
I'm trying to make visible or invisible a textbox depending on whether a
checkbox is clicked. Both controls are inside the same gridview. I've
tried program this in the CheckedChanged event but visual studio keeps
telling me the textbox control is not declared. Here's how the controls
are in gridview:

<edititemtemplate>
<asp:CheckBox checked='<%#Eval("chkfield")%>'
ID="chk1" runat="server" TextAlign="Left" AutoPostBack="true"
OnCheckedChanged="chk1_CheckedChanged" />
<asp:TextBox id="txt1" Text='<%#Eval("textfield")
%>' Width="30" MaxLength="1" runat="server" />
</edititemtemplate>

What should be the correct way of doing this? Does this has to be done in
one of those row-level event of the gridview? Appreciate any advice.

Nov 18 '08 #2

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

Similar topics

1
by: Bill44077 | last post by:
I am dynamically adding a checkbox in a gridview and I find there are several things that I cannot figure out how to address. 1. The width of the checkbox column is very wide. I've tried adding...
0
by: Jayender | last post by:
Hi , I have placed checkbox in my gridview .. now when i check the chekbox and click anybutton the checkbox becomes unchecked. but when i normally add checkbox in the page it doesnt happen but...
1
by: mercercreek | last post by:
This one should be easy. Hope someone has a clue. Simple Scenario: Gridview with mulitple rows, each row with a checkbox. The user checks boxes of her choice. Clicks a button on the form (not in...
9
by: mike7510uk | last post by:
Hi, I am using a gridview with a templatefield containing a checkbox. I want to update the database with a 1 or 0 depending on if a checkbox is checked or unchecked (then use the 1 or 0 later on...
2
by: JonBosker | last post by:
I am having a strange problem - my GridView is displaying bits (from SQL Server) as checkboxes (which is fine) but it shows each alternating one centrally aligned. Heading1 Heading2 Text ...
7
by: Vladzeem | last post by:
Hi there, I have a problem to access a checkbox inside GridView using row index using javascript. Here is the code: var c; var cellValue; var rCount = 0; var cellControl; gridViewCtl =...
1
by: Ben | last post by:
Hi, I'm designing a c# page and trying to add a checkbox column to a GridView, I've added a Template Row (as described at: http://aspnet.4guysfromrolla.com/articles/052406-1.aspx) and in the...
2
by: sana krishna | last post by:
i use ASP.NET 2005 I use gridview to display the Employ information.And display a checkbox filed inside the gridview add as a template. I want to store the emp_no into a variable when i checked...
0
by: dotnetrookie | last post by:
Hi This is my 1st post.I have two checkbox columns in gridview binded through item template. The checkboxes are Category and Subcategory. I have actually removed the duplicate values in the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
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...
0
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...

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.