Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Pass Eval in JavaScript function as parameter in Gridview?

How to pass Eval value to JavaScript function as parameter in Gridview?

I want to pass dynamic row value to JavaScript function to perform some action.

For example I want select checkbox in grid-view  if user is active only on click.

Client side grid view code:

<asp:GridView runat="server" ID="dgPublisData" >                 
<asp:TemplateField HeaderText="Cancel" Visible="true">
<input type="checkBox" ID="isActive" runat="server" class="cs-button" onclick='<%# string.Format("EnableData (\"{0}\");return false;",Convert.ToBoolean(Eval("User .IsActiveUser")) %>'  Value="Status"  '/>     


JavaScript function


function EnableData (isActiveUser) {
    // do some script here
if (isActiveUser == "true") {
     //do some script here to select checkbox
          // add some notification

Invalid entry,please enter valid data.