Datagrid Row Selection

Discussion in 'ASP .Net Datagrid Control' started by Toby Riley, Oct 7, 2003.

  1. Toby Riley

    Toby Riley Guest

    Any ideas on how i would select a row from a datagrid using a mouse click
    event on the row. I need to set the selectedindex. I using the following
    code to create a rollover as the mouse moves through the rows. All I need is
    the bit to make the onclick event work.

    Private Sub dgUserList_ItemDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    dgUserList.ItemDataBound

    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    ListItemType.AlternatingItem Then
    e.Item.Attributes.Add("onmouseover",
    "this.style.backgroundColor='Silver'")
    e.Item.Attributes.Add("onmouseout",
    "this.style.backgroundColor='white'")
    End If

    End Sub

    Thanks in advance

    Toby
    Toby Riley, Oct 7, 2003
    #1
    1. Advertising

  2. Check out this article,
    http://www.microsoft.com/india/msdn/articles/Master Detail DataGrid.aspx

    --
    Saravana
    Microsoft MVP - ASP.NET
    www.extremeexperts.com



    "Toby Riley" <> wrote in message
    news:#...
    > Any ideas on how i would select a row from a datagrid using a mouse click
    > event on the row. I need to set the selectedindex. I using the following
    > code to create a rollover as the mouse moves through the rows. All I need

    is
    > the bit to make the onclick event work.
    >
    > Private Sub dgUserList_ItemDataBound(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    > dgUserList.ItemDataBound
    >
    > If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    > ListItemType.AlternatingItem Then
    > e.Item.Attributes.Add("onmouseover",
    > "this.style.backgroundColor='Silver'")
    > e.Item.Attributes.Add("onmouseout",
    > "this.style.backgroundColor='white'")
    > End If
    >
    > End Sub
    >
    > Thanks in advance
    >
    > Toby
    >
    >
    Saravana [MVP], Oct 8, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?YmFjazJncmlk?=

    highlight datagrid row on radiobutton selection

    =?Utf-8?B?YmFjazJncmlk?=, Sep 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    468
    =?Utf-8?B?YmFjazJncmlk?=
    Sep 13, 2004
  2. =?Utf-8?B?QmlkYXJrb3Rh?=

    DataGrid Client Side row selection

    =?Utf-8?B?QmlkYXJrb3Rh?=, May 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    539
    =?Utf-8?B?QmlkYXJrb3Rh?=
    May 23, 2005
  3. =?Utf-8?B?cm9kY2hhcg==?=

    datagrid row selection

    =?Utf-8?B?cm9kY2hhcg==?=, Aug 24, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    560
    =?Utf-8?B?cm9kY2hhcg==?=
    Aug 25, 2005
  4. Simon Niederberger
    Replies:
    2
    Views:
    16,501
    Christian Kaufhold
    Jan 7, 2005
  5. D
    Replies:
    0
    Views:
    206
Loading...

Share This Page