I am pretty sure rowselect will work like in
this post. UpdatePanel doesn't influence it. I use this a lot.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
Ali.M.Habib
Member
22 Points
82 Posts
cannot highlight gridview row onclick
Nov 09, 2010 02:26 PM|LINK
Hi all,
I haveissue with gridview
I use gridview inupdate panel like this
I use<asp:ButtonField Text="DoubleClick" CommandName="DoubleClick" Visible="false" /> for double click handeling on row
I need when click on row it be highlighted so I use the following
protected void GridSearchResult_RowCreated(object sender, GridViewRowEventArgse)
{
if (e.Row.RowType == DataControlRowType
.DataRow)
{
string
key = KEY.ToString();
e.Row.Attributes.Add(
"id"
, key);
e.Row.Attributes.Add(
"onclick","javascript:ChangeRowColor(this)"
);
and the javascript is
<script language="javascript" type
="text/javascript">
function
ChangeRowColor(row)
{
var
color = row.style.backgroundColor;
if (color != '#ffff66'
) oldColor = color;
if (color == '#ffff66'
) row.style.backgroundColor = oldColor;
else row.style.backgroundColor = '#ffff66'
;
}
</script>
I tried to remove the grid view from the updatepanel but it give any result
any suggesion please
manoj0682
Star
8479 Points
1499 Posts
Re: cannot highlight gridview row onclick
Nov 09, 2010 03:02 PM|LINK
check below link
http://netomatix.com/development/gridviewrowselectedstyle.aspx
Manoj Karkera
Ahmed Moosa
Star
7784 Points
1232 Posts
Re: cannot highlight gridview row onclick
Nov 09, 2010 03:11 PM|LINK
hi
try to do it using Jquery Like this : (just copy and paste )
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#GridView1 tr").mouseover(function () { $(this).css("background", "red"); }) ; $("#GridView1 tr").mouseout( function () { $(this).css("background", "white"); }); }); </script>do not forget to replace GridView1 with you GridViewID
Thanks
MCC - MCPD -MCTS
Ali.M.Habib
Member
22 Points
82 Posts
Re: cannot highlight gridview row onclick
Nov 10, 2010 05:27 AM|LINK
dear manoj0682
I tried it and gve javascrpt error
gridview1 (mygridview name asi changed the ggrid name he use with mine ) is undefined any suggestion
Best regards
Ali.M.Habib
Member
22 Points
82 Posts
Re: cannot highlight gridview row onclick
Nov 10, 2010 05:52 AM|LINK
it not work withme becaause the gridview on update panel any suggestion please
ShilpaSunil
Member
505 Points
144 Posts
Re: cannot highlight gridview row onclick
Nov 10, 2010 07:40 AM|LINK
Hi,
Try using these links
http://www.dotnetcurry.com/ShowArticle.aspx?ID=123&AspxAutoDetectCookieSupport=1
http://www.eggheadcafe.com/community/aspnet/17/10195665/changing-selective-row-colors-in--gridview.aspx
http://www.highoncoding.com/Articles/174_Change_GridView_RowColor_OnMouseClick.aspx
Ahmed Moosa
Star
7784 Points
1232 Posts
Re: cannot highlight gridview row onclick
Nov 10, 2010 11:38 AM|LINK
hi
ok try this :
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#UpdatePanel1 #GridView1 tr").mouseover(function () { $(this).css("background", "red"); }) ; $("#UpdatePanel1 #GridView1 tr").mouseout(function () { $(this).css("background", "white"); }); }); </script>hope this helps
Ahmed
MCC - MCPD -MCTS
superguppie
All-Star
48225 Points
8679 Posts
Re: cannot highlight gridview row onclick
Nov 12, 2010 12:23 PM|LINK
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.