Thursday, August 18, 2011

Javascript in Hyperlink Button in Gridview


In this Blog like to share you how we can do some scripting in Gridview hyperlink & conditional formatting.
below is example

in Text you can see i am getting value from gridview IsActive and making text change if  true the DeActive else Activate

Onclick i am opening a popup window for Activation and Deactivation on value which i get in IsActive
if it true then run a javascript function ConfirmDeActiveUsers,in this Function i can pass value with the help of following way.Command is nothing but value i need to pass it to javascript function or can even use javascript over there for example i can use Alert Function in Javascript to alert ID of that particular item

<asp:HyperLink Text='<%# Convert.ToBoolean(Eval("IsActive")) ? "Deactivate" : "Activate" %>' runat="server" ID="hyperlnkView" OnClick='<%# Convert.ToBoolean(Eval("IsActive")) ? Eval("command","return ConfirmDeActiveUsers(\"{0}\");") : Eval("command","ConfirmNonActiveUsers(\"{0}\");") %>' ></asp:HyperLink>

No comments:

Post a Comment