asp.net - How to pass checkbox id inside gridview from vb.net to javascript -


I have Gridwu which box I header and item templates to pass I now I check ID vb JavaScript Want this as follows.

  Protected Sub RowDataBound (ByVal as the object, as ByVal e GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow then dim headerchk new checkbox headerchk = DirectCast (gridview.HeaderRow .FindControl ( "chkheader"), box) dim childchk Czech box = DirectCast as (e.Row.FindControl ( "chkRow"), box) as childchk.Attributes.Add ( "onclick", "javascript: Selectchildcheckboxes ( '' + headerchk.ClientID + '') ") 'but this line gives me error finally end Sub  

will JavaScript function,

<> function SelectheaderCheckboxes (Headerchk) ​​pre {i F (headerchk.checked) {// code}}

I'm getting error "object not set for an instance of an object".

Instead of adding attributes on the server side, at the top of your javascript while adding and designing the onclick event Add the following lines

These lines are for headerCheckbox,

  var gvcheck = document.getElementById ( '. & lt;% = gridview.clientid% & gt; '); Var chks = gvcheck.rows [0] .getElementsByTagName ("input"); Header = Chucks [`index of your checkbox]. .id;  

The design should be such,

  & lt; Asp: TemplateField & gt; & Lt; ItemTemplate & gt; & Lt; Asp: checkbox id = "chkRow" onclick = "javascript: selectchildcheckboxes ();" Runat = "server" /> & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt;  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -