views:

849

answers:

1

In gridview's column i have a linkbutton and a label under it.

I want to hide/unhide label when linkbutton is clicked. I want to use javascript because i don't want any postbacks.

My java scripts function needs to receive the reference of label which corresponding to the linkbutton that was clicked. (then i will use document.getElementById(inputRef).style.display) to toggle the state.

How do I pass the needed label's reference to the javascript function?

Thanks

A: 

One way is to manage this in your grid's ItemDataBound event handler and pass the label's ClientID as a string paramater for that JavaScript call.

e.g. myLinkButton.attributes.Add("onclick","javascript:HidColumn('" + myLabel.ClientID + "');");

deadbug
you mean RowDataBound?
Yes, sorry, it's RowDataBound. I was thinking of the DataGrid control when I mentioned ItemDataBound :-). Concept is all the same though...
deadbug
I asked a follow up question, if you know the answer you are welcome to help again :)http://stackoverflow.com/questions/1022570/hiding-unhiding-control-in-gridviews-column-shifting-problem