Getting the data key field value when selecting a row in a datagrid...

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Getting the data key field value when selecting a row in a datagrid...

    Hi,

    I am trying to return the data key field value from a dataset when I select
    a row in a datagrid after the datagrid has been bound to a dataset.

    When I an the Edit, Update and Cancel row I can return the DataKey using the
    sub listed below. However, the select button does not have
    'DataGridCommandEventArgs' as one of it's parameters so I cannot use the
    same command.

    -----------
    Public Sub UpdateCommand(ByVal sender As System.Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
    DataGrid1.UpdateCommand
    Response.Write("The datakey for this row is:" &
    DataGrid1.DataKeys(e.Item.ItemIndex).ToString)
    End Sub
    -----------

    Anybody any ideas?

    Thanks in advance,

    Stu



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.505 / Virus Database: 302 - Release Date: 30/07/2003


    Stu Guest

  2. Similar Questions and Discussions

    1. Selecting one particular field in the same Access database table?
      Is there a way of selecting one particular field in the same Access database table? eg. database is - ID: 1 ...
    2. selecting datagrid row
      Hello asp.net I've stuck a Select button from the property builder on my grid (Col 0). Upon click I'd like it to return the value in Col 1...
    3. datagrid with edit option selecting data
      In asp.net web page that has a datagrid, how do you get the value from the selected edit textboxes?
    4. Selecting a row in datagrid
      Hi, I want to use Datagrid with a button or any other way so that I can select one row that is required. Actually the database is searched for a...
    5. Datagrid Data Field question
      My datagrid consist of a Bound Column where the Data Field = Origin. I would like the following Bound Column to display either Origin or...
  3. #2

    Default Getting the data key field value when selecting a row in a datagrid...

    You can get the data key value from the ItemCommand event
    when a user clicks on the datagrid select button. Then
    use this value to do whatever you want.
    >-----Original Message-----
    >Hi,
    >
    >I am trying to return the data key field value from a
    dataset when I select
    >a row in a datagrid after the datagrid has been bound to
    a dataset.
    >
    >When I an the Edit, Update and Cancel row I can return
    the DataKey using the
    >sub listed below. However, the select button does not have
    >'DataGridCommandEventArgs' as one of it's parameters so I
    cannot use the
    >same command.
    >
    >-----------
    >Public Sub UpdateCommand(ByVal sender As System.Object,
    ByVal e As
    >System.Web.UI.WebControls.DataGridCommandEventArg s)
    Handles
    >DataGrid1.UpdateCommand
    > Response.Write("The datakey for this row is:" &
    >DataGrid1.DataKeys(e.Item.ItemIndex).ToString)
    >End Sub
    >-----------
    >
    >Anybody any ideas?
    >
    >Thanks in advance,
    >
    >Stu
    >
    >
    >
    >---
    >Outgoing mail is certified Virus Free.
    >Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    >Version: 6.0.505 / Virus Database: 302 - Release Date:
    30/07/2003
    >
    >
    >.
    >
    makthar 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