Datagrid Row Selection

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Datagrid Row Selection

    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 Guest

  2. Similar Questions and Discussions

    1. DataGrid, selection and filtering
      Like a lot of developers I've recently moved from Flex 2 to Flex 3. I've noticed a bit of a change in how the DataGrid/List classes deal with...
    2. Datagrid selection and rollOver effects
      I see that I can set the selectionColor and rollOverColor, but is there a way to make selection and rollover use borders instead? My rows are color...
    3. Datagrid: single cell selection
      Did anyone ever reply to this question yet? Please do if you know. Thanks.
    4. selection of fields in datatable for Datagrid
      I'd like my Datagrid shows only some columns in the datatable(I'd like to change the name of some columns too) How can I do that? Thanks for...
    5. --- Multiple Selection, with Paging in the Datagrid ---
      Hi, Hard work but possible. You need to keep internal data (add fields to row data) on the server to track the selected rows. Natty Gur, CTO...
  3. #2

    Default Re: Datagrid Row Selection

    Check out this article,
    [url]http://www.microsoft.com/india/msdn/articles/Master%20Detail%20DataGrid.aspx[/url]

    --
    Saravana
    Microsoft MVP - ASP.NET
    [url]www.extremeexperts.com[/url]



    "Toby Riley" <toby.riley@exmlsystems.com> wrote in message
    news:#n2EUVQjDHA.2512@TK2MSFTNGP11.phx.gbl...
    > 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] Guest

  4. #3

    Default Datagrid Row Selection

    Hello,

    I have a datagrid in my aspx page and the function Get_This() in my
    code.

    I am trying to do the following:
    1. When the mouse clicks anywhere inside a datagrid's row the function
    Get_This is called.
    2. In the function Get_This the record ID of the selected row should be
    available.

    Is this possible?
    How can I do this?

    Thanks,
    Miguel

    Shapper Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139