62,241
社区成员




script type="text/javascript">
var prevselitem = null;
function selectx(row) {
if (prevselitem != null) {
prevselitem.style.backgroundColor = '';
}
row.style.backgroundColor = '#75BAFF';
prevselitem = row;
}
</script>
protected void GV_DATA_RowDataBound( object sender, GridViewRowEventArgs e )
{
if( e.Row.RowType == DataControlRowType.DataRow )
{
e.Row.Attributes.Add( "onmouseover", "if(this!=prevselitem){this.style.backgroundColor='#Efefef'}" );
e.Row.Attributes.Add( "onmouseout", "if(this!=prevselitem){this.style.backgroundColor=''}" );
e.Row.Attributes.Add( "onclick", e.Row.ClientID.ToString() + ".checked=true;selectx(this)" );
e.Row.Attributes[ "style" ] = "Cursor:hand";
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (oldRow.Value != "" && oldRow.Value.Equals(e.Row.ClientID))
{
e.Row.Attributes.Add("style", "background-color:#e6c5fc");
}
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
e.Row.Attributes.Add("onclick", string.Format("rowStyleChange('{0}','{1}','1')", e.Row.ClientID, e.Row.Cells[0].Text));
}
}
}
<script type="text/javascript" language="javascript">
function rowStyleChange(id, value) {
if (document.getElementById("oldRow").value == "") {
document.getElementById("oldStyle").value = document.getElementById(id).runtimeStyle.cssText;
document.getElementById("oldRow").value = id;
document.getElementById(id).runtimeStyle.cssText = "background-color:#e6c5fc";
}
else {
document.getElementById(document.getElementById("oldRow").value).runtimeStyle.cssText = document.getElementById("oldStyle").value;
document.getElementById("oldStyle").value = document.getElementById(id).runtimeStyle.cssText;
document.getElementById("oldRow").value = id;
document.getElementById(id).runtimeStyle.cssText = "background-color:#e6c5fc";
}
document.getElementById("clickId").value = value;
document.getElementById("btnSearch").click();
}
</script>
aspx--->
<input type="hidden" id="oldRow" name="oldRow" runat="server" />
<input type="hidden" id="oldStyle" name="oldStyle" runat="server" />
<input type="hidden" id="clickId" name="clickId" runat="server" />
<asp:Button ID="btnSearch" runat="server" OnClick="btn_Click" />
[code=C#]
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (oldRow.Value != "" && oldRow.Value.Equals(e.Row.ClientID))
{
e.Row.Attributes.Add("style", "background-color:#e6c5fc");
}
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
e.Row.Attributes.Add("onclick", string.Format("rowStyleChange('{0}','{1}','1')", e.Row.ClientID, e.Row.Cells[0].Text));
}
}
}