AjaxDataControls : GridView Attaching javascript to a row when OnRowDataBound is fired

Last post 08-04-2008 4:48 PM by xxxd. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-04-2008 4:34 PM

    AjaxDataControls : GridView Attaching javascript to a row when OnRowDataBound is fired

    I am in the process of converting a asp:GridView control to  AjaxDataControl:GridView...

    My old grid has a 'hover' i.e when the mouse hovers on a row in the grid view the row is highlighted,and when the user clicks on the row the row is selected by settings its td back ground color to dark green..using the old grid view this was pretty simple , i just did ..


    On GridView_OnRowDataBound(sender,GridViewRowEventArgs)

    if(e.Row.RowType == DataControlRowType.DataRow)
    {
     
        ...
        e.Row.Attributes.Add("onmouseover","this.style.backgroundColor = "#F5F5F5")

        e.Row.Attributes.Add("onmouseover","this.style.backgroundColor = "#FFFFFF")
    }

    Now i dont know what has to be done to make this work with gridview ajaxdata control since there is no way to add any custom javascript when the rowDataboundEvent fires

    1. function rowDataBound(sender, e)  
    2. {  
    3.  if (e.get_row().get_isDataRowType())
       {

                    //Thinking.....Thinking Thinking ....... Please help!!!

               }

     

    Filed under:
  •  Advertisement

    Featured Advertisement

     
  • 08-04-2008 4:45 PM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: AjaxDataControls : GridView Attaching javascript to a row when OnRowDataBound is fired

    Get the latest version. It has the onmouseover and onmouseout events. Also check the mouseover.aspx examples. This should solve your problem.

    Please get the files from the /AjaxDataControls folder. The examples are in that folder as well. There is something wrong with the folder structure.

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 08-04-2008 4:48 PM In reply to

    • xxxd
    • Top 10 Contributor
    • Joined on 12-18-2006
    • Slacker
    • Points 19,057

    Re: AjaxDataControls : GridView Attaching javascript to a row when OnRowDataBound is fired

    It would be almost the same. 

    function onRowCreated(sender, e)
    {
     if (e.get_row().get_isDataRowType())

     {
      var row = e.get_row();

      var tr = row.get_container();
     

      tr.onmouseover = function(){ this.className = 'rowMouseOver' };
      tr.onmouseout = function(){ this.className = 'rowMouseOut' };
     }
    }

     

    Also, the newest updates have added mouseover event so it is even easier.

    I believe other client side events will be gradually added from server side as well. So keep an eye on it

  • 08-04-2008 4:48 PM In reply to

    • xxxd
    • Top 10 Contributor
    • Joined on 12-18-2006
    • Slacker
    • Points 19,057

    Re: AjaxDataControls : GridView Attaching javascript to a row when OnRowDataBound is fired

Page 1 of 1 (4 items)