Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > gridview and attribute

Thread Tools

gridview and attribute

Al Smith
Posts: n/a
I am trying to attach client side javascript to a check box contained within
the gridview control using the attribute method. My aspx code is:
<asp:TemplateField HeaderText="Set Password">
<asp:CheckBox ID="chkSetPassword" runat="server" Checked='<%#
Bind("SetPassword") %>' />
<asp:CheckBox ID="chkSetPassword" runat="server" Checked='<%#
Bind("SetPassword") %>'
Enabled="false" />

In the code behind, RowCreated() event I use the chk.Attributes to attempt
the wiring of the onclick event to my JS:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)

if (e.Row.RowState == DataControlRowState.Edit) {
CheckBox chk = (CheckBox)e.Row.FindControl("chkSetPassword");
if (chk != null){
chk.Attributes["onclick"] = "javascriptnclickSetPassword();";

When I do a view source in the browser I get:
<input id="GridView1_ctl02_chkSetPassword" type="checkbox"
name="GridView1$ctl02$chkSetPassword" onclick="flagDataChanged(this);" />

Is there a was to add my JS event to this?


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex attribute with Attribute and simpletype kanpeter XML 0 10-26-2010 09:41 AM
attr_reader, default attribute value, and rdoc of attribute dkmd_nielsen Ruby 6 11-26-2008 05:40 PM
Difference between empty attribute and undefined attribute Javascript 4 04-24-2007 02:52 PM
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
XSLT: Making attribute to parent attribute Bostonasian XML 1 09-18-2005 07:30 AM