This is a follow up to my previous question: link text
In gridview's column i have a linkbutton and a label under it.
I want to hide/unhide label when linkbutton is clicked. I use javascript because i don't want any postbacks. The code:
protected void gvwComments_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lButton = ((LinkButton)e.Row.Cells[2].FindControl("lbtnExpand"));
Label label = ((Label)e.Row.Cells[2].FindControl("lblBody"));
lButton.Attributes.Add("onclick", string.Format("HideLabel('{0}'); return false;", label.ClientID));
}
}
function HideLabel(button) {
var rowObj = document.getElementById(button);
if (rowObj.style.display == "none") {
rowObj.style.display = "block";
}
else {
rowObj.style.display = "none";
}
}
The problem is that when I unhide the label by clicking on button, linkbutton is shifted a a bit upper it's original position in the cell. Is it possible to preserve linkbutton's position in the gridviews cell?