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

 

JavaScript function

 

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