473,725 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code Behind error for checkbox in datagrid

I have the following asp:checkbox as a row in my datagrid. and im trying to
write code on the onCheckedChange d event of it. The code im trying to write
is incorrect as im getting build errors. What im trying to do is populate a
label on my aspx page with the contents of the row in the database which I
have checked. When I uncheck the checkbox I want the label to be set to
blank so as it can be populated again when another checkbox in the datagrid
is ticked. The html for the checkbox is below along with the code-behind
page. Can someone tell me what i've done wrong and how I can fix this.
Thanks for any help anyone can give.

<asp:TemplateCo lumn HeaderImageUrl= "../Images/Tick.gif">
<HeaderStyle HorizontalAlign ="Center" Height="20px" Width="10px"
CssClass="dgHea der" VerticalAlign=" Middle"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center" Width="10px"
VerticalAlign=" Middle"></ItemStyle>
<ItemTemplate >
<asp:CheckBox ID="chkSelectio n" Runat="server" AutoPostBack="T rue"
OnCheckedChange d="myFunction"> </asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>

public void myFunction(obje ct sender, System.EventArg s e)
{
this.lbldatagri drow.Text = e.Item.Cells[0].Text;
}
Build Error: -
'System.EventAr gs' does not contain a definition for 'Item'

Nov 16 '05 #1
1 4495
It looks like your event handler has the wrong signature. If you want to reference the datagrid row (item) corresponding to the checked checkbox, then you'll have to pass the item along with the CheckBox's CheckedChange event.
The System.EventArg s class has no property called Item. That's where your compile failure is stemming from. The Item property is typically associated with custom event arguments (like those provided when a DataGrid row is selected).

Hope this helps.
I have the following asp:checkbox as a row in my datagrid. and im trying to
write code on the onCheckedChange d event of it. The code im trying to write
is incorrect as im getting build errors. What im trying to do is populate a
label on my aspx page with the contents of the row in the database which I
have checked. When I uncheck the checkbox I want the label to be set to
blank so as it can be populated again when another checkbox in the datagrid
is ticked. The html for the checkbox is below along with the code-behind
page. Can someone tell me what i've done wrong and how I can fix this.
Thanks for any help anyone can give.

<asp:TemplateCo lumn HeaderImageUrl= "../Images/Tick.gif">
<HeaderStyle HorizontalAlign ="Center" Height="20px" Width="10px"
CssClass="dgHea der" VerticalAlign=" Middle"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center" Width="10px"
VerticalAlign=" Middle"></ItemStyle>
<ItemTemplate >
<asp:CheckBox ID="chkSelectio n" Runat="server" AutoPostBack="T rue"
OnCheckedChange d="myFunction"> </asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>

public void myFunction(obje ct sender, System.EventArg s e)
{
this.lbldatagri drow.Text = e.Item.Cells[0].Text;
}
Build Error: -
'System.EventAr gs' does not contain a definition for 'Item'


User submitted from AEWNET (http://www.aewnet.com/)
Nov 16 '05 #2

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

Similar topics

0
909
by: Stephen | last post by:
I have the following asp:checkbox as a row in my datagrid. and im trying to write code on the onCheckedChanged event of it. The code im trying to write is incorrect as im getting build errors. What im trying to do is populate a label on my aspx page with the contents of the row in the database which I have checked. When I uncheck the checkbox I want the label to be set to blank so as it can be populated again when another checkbox in the...
18
18408
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
2
2059
by: Marty | last post by:
I have a numeric Oracle field which stores -1 for true and 0 for false. I am trying to populate a checkbox in a datagrid. In my SQL statement, I used the Decode function so that when it populates the dataset that I would store the string 'true' and 'false' rather than a numeric value. I did this because I thought it would make it easier to actually set the value in the checkbox. Anyway, I bind the dataset to the datagrid. In my HTML...
2
1356
by: Kurt Schroeder | last post by:
Still new to code behind so i'm not sure what the problem is (i'm using visualStudio.net for the first time) like my last question i'll bet this has a quick answer. thanks kes here is the error: and please for give the excessive text Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about...
10
2442
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox control in a datagrid? Now I have a Select column but the problem is that the user needs to select more than one record and send them all to print, instead of being one by one like is now with the Select column. Another question, is it possible to...
6
5515
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp; DataBinder.Eval(Container.DataItem,"StoreEmail") &amp; "&amp;Subject=" &amp; DataBinder.Eval(Container.DataItem,"ProductName") ....
2
1841
by: Fabrice | last post by:
Hello, First, thanks to felix for his answer. But :-( , I'm feeling newbie :! I' don't understand all the situation. The trouble : Always in the road whith my Datagrid and my ItemTemplate with a Control HyperLink. I would like to fix many properties of this Control Hyperlink in the Code
9
1593
by: Rekha | last post by:
The data is filled in datagrid. I want to know how to add a checkbox column in datagrid? In the runtime, checkbox is checked then instead of checkbox value the (caseID )column value is retained. I know there is a lot of article on datagrid with checkbox but nothing helped me . Can anyone help me how to proceed ? Thanks
1
2570
by: graphicsxp | last post by:
Hi, I have a checkboxfield in my gridview: <asp:CheckBoxField DataField="Analysed" HeaderText ="Analysed"> <ItemStyle width="20px" /> </asp:CheckBoxField> How can I reference the field from my code-behind ? I can't see any properties/methods on the grid to access it. There's no ID so I can't do FindControl :(
0
8888
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...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
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
9113
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
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
6702
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...
1
3221
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

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.