选择后更改gridview行的颜色 [英] change th colour of the gridview row upon selection
问题描述
我想更改/显示在内部选择的行的颜色
我使用的是带有滚动条的GridView.因此所有数据都在GridView内部
行形式.因此,每当我选择一行时,它都会再次转到第一行,并且仍然
那么被点击的行的颜色就不会显示出来.
我在gridview中使用了RowCommand事件,以便针对
的数据
选定的行可以在另一个GridView中看到.
我使用了这段代码-:
Hi,
I want to change/show the colour of the row that is being selected inside
the GridView.I use a GridView having Scrollbars.So all data is inside the GridView
in Row form.Hence whenever i select a row it again goes to the first line and still
then the colour of the Row that has been clicked doesn''t show up.Also
ihave used the RowCommand event inside the gridview so that data against the
selected row can be seen in another GridView.
i used this code-:
Private Sub GridView_chqdetails_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView_chqdetails.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onClick", "javascript:change_grdviewrow_colour('" & e.Row.ClientID & "')")
End If
End Sub
在前端-:
In frontend-:
function change_grdviewrow_colour(current_row)
{ /*This Fuction is used to Change the Colour of the Row in the GridView whenever
it is being Clicked or Selected*/
var previous_row;
//Check whether the Current Row clicked is same as the Previous Row Clicked in the GridView.
if(previous_row==current_row)
{
return;//Do Nothing
}
//If any row has been clicked or selected before.
else if(previous_row!=null)
{
//Change the Colour of the Previously clicked or selected Row of GridView to normal.
document.getElementById(previous_row).style.backgroundcolor="#ffffff";
}
//Assign the LIght Yellow Colour to the newly clicked or selected Row of the GridView.
document.getElementById(current_row).style.backgroundcolor="#ffffda";
//Now assign the ID of the Newly selected Row of GridView or "current_row" to the
//"Previous_row" so that a New Row can be Selected or Clicked and it''s Colour can change.
previous_row=current_row;
} /*End of Function.*/
推荐答案
希望此 [ ^ ]可能会为您提供帮助.
Hope this[^] might help you.
^ ]
上面的链接会很有帮助.只需浏览上面的链接,您就会找到解决方案.
http://www.google.com/search?hl=en&biw=1024&bih=547&q=gridview+selected+row+color+change&aq=1b&aqi=g-v1g-b2&aql=f&oq=gridview+row+selected+color[^]
The above link will be helpful.Just navigate the links above and you will find your solution.
这篇关于选择后更改gridview行的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!