T
teejayem
I am new to asp.net.
I have a grid view that is bound to a dataview.
I have used a small javascript to select the rows in the gridview see
below:-
<script language="javascript" type="text/javascript">
var oldgridSelectedColor;
function setMouseOverColor(element) {
oldgridSelectedColor = element.style.backgroundColor;
element.style.backgroundColor='silver';
element.style.cursor='hand';
element.style.textDecoration='underline';
}
function setMouseOutColor(element) {
element.style.backgroundColor=oldgridSelectedColor;
element.style.textDecoration='none';
}
</script>
Protected Sub DefaultGridView_RowDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
DefaultGridView.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes("onmouseover") =
"javascript:setMouseOverColor(this);"
e.Row.Attributes("onmouseout") =
"javascript:setMouseOutColor(this);"
e.Row.Attributes("onclick") =
ClientScript.GetPostBackClientHyperlink(DefaultGridView, "Select$" &
CStr(e.Row.RowIndex))
End If
End Sub
This works fine.
The problem I am having is that when an item is selected the grid view
changes size and the header column text jumps around.
I can set a fixed width to the gridview but this doesn't stop the
columns changing shape/size.
Is there an easy way to resolve this?
I have a grid view that is bound to a dataview.
I have used a small javascript to select the rows in the gridview see
below:-
<script language="javascript" type="text/javascript">
var oldgridSelectedColor;
function setMouseOverColor(element) {
oldgridSelectedColor = element.style.backgroundColor;
element.style.backgroundColor='silver';
element.style.cursor='hand';
element.style.textDecoration='underline';
}
function setMouseOutColor(element) {
element.style.backgroundColor=oldgridSelectedColor;
element.style.textDecoration='none';
}
</script>
Protected Sub DefaultGridView_RowDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
DefaultGridView.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes("onmouseover") =
"javascript:setMouseOverColor(this);"
e.Row.Attributes("onmouseout") =
"javascript:setMouseOutColor(this);"
e.Row.Attributes("onclick") =
ClientScript.GetPostBackClientHyperlink(DefaultGridView, "Select$" &
CStr(e.Row.RowIndex))
End If
End Sub
This works fine.
The problem I am having is that when an item is selected the grid view
changes size and the header column text jumps around.
I can set a fixed width to the gridview but this doesn't stop the
columns changing shape/size.
Is there an easy way to resolve this?