Hiding/Unhiding Control in Gridview’s column - shifting problem
Posted
by lupital
on Stack Overflow
See other posts from Stack Overflow
or by lupital
Published on 2009-06-20T21:15:11Z
Indexed on
2010/03/28
3:03 UTC
Read the original article
Hit count: 265
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?
© Stack Overflow or respective owner