gridview and attribute

A

Al Smith

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">
<EditItemTemplate>
<asp:CheckBox ID="chkSetPassword" runat="server" Checked='<%#
Bind("SetPassword") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSetPassword" runat="server" Checked='<%#
Bind("SetPassword") %>'
Enabled="false" />
</ItemTemplate>
</asp:TemplateField>


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"] = "javascript:eek:nclickSetPassword();";
}
}
}


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?

Thanks
Al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top