How to determine which cell was clicked in as ASP.NET DataGrid

Discussion in 'ASP .Net Datagrid Control' started by Daniel Walzenbach, Jun 1, 2004.

  1. Hi,



    I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to http://msdn.microsoft.com/library/d...QuestionsAboutASPNETDataGridServerControl.asp, Selecting Rows by Clicking Anywhere).



    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
    ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
    Handles DataGrid1.ItemDataBound
    Dim itemType As ListItemType = e.Item.ItemType
    If ((itemType = ListItemType.Pager) Or _
    (itemType = ListItemType.Header) Or _
    (itemType = ListItemType.Footer)) Then
    Return
    Else
    Dim button As LinkButton = _
    CType(e.Item.Cells(0).Controls(0), LinkButton)
    e.Item.Attributes("onclick") = _
    Page.GetPostBackClientHyperlink(button, "")
    End If
    End Sub

    Additionally I want to be able to know which cell was clicked. Does anybody know how this can be done?



    Thank you a lot in advance!



    Daniel
     
    Daniel Walzenbach, Jun 1, 2004
    #1
    1. Advertising

  2. "Daniel Walzenbach" <> wrote in message news:...
    Hi,



    I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to http://msdn.microsoft.com/library/d...QuestionsAboutASPNETDataGridServerControl.asp, Selecting Rows by Clicking Anywhere).



    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
    ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
    Handles DataGrid1.ItemDataBound
    Dim itemType As ListItemType = e.Item.ItemType
    If ((itemType = ListItemType.Pager) Or _
    (itemType = ListItemType.Header) Or _
    (itemType = ListItemType.Footer)) Then
    Return
    Else
    Dim button As LinkButton = _
    CType(e.Item.Cells(0).Controls(0), LinkButton)
    e.Item.Attributes("onclick") = _
    Page.GetPostBackClientHyperlink(button, "")
    End If
    End Sub

    Additionally I want to be able to know which cell was clicked. Does anybody know how this can be done?



    Thank you a lot in advance!




    I'm not certain, but I think that if you use something other than "" for the second parameter to GetPostBackClientHyperlink, then the parameter will be passed as Request.Form("__EVENTARGUMENT").
    --
    John Saunders
    johnwsaundersiii at hotmail
     
    John Saunders, Jun 2, 2004
    #2
    1. Advertising

  3. Hi Daniel,

    I'm viewing this post and find it is a duplicated one with another thread
    with same title in
    Newsgroups: microsoft.public.dotnet.framework.aspnet

    I've posted a reply and provided my suggestoins in that one. I'd appreciate
    if you'd have a look there. Also, if you feel it convenient that we
    continue to discuss in that thread, please feel free to followup there.
    Thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Jun 2, 2004
    #3
  4. Daniel Walzenbach

    SoftLion Guest

    Could you copy-paste here please ?

    "Steven Cheng[MSFT]" <> a écrit dans le message
    de news:...
    > Hi Daniel,
    >
    > I'm viewing this post and find it is a duplicated one with another thread
    > with same title in
    > Newsgroups: microsoft.public.dotnet.framework.aspnet
    >
    > I've posted a reply and provided my suggestoins in that one. I'd

    appreciate
    > if you'd have a look there. Also, if you feel it convenient that we
    > continue to discuss in that thread, please feel free to followup there.
    > Thanks.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    >
     
    SoftLion, Jun 3, 2004
    #4
  5. Steven,

    thanks for your help! I tried what you posted and it worked perfectly well.
    I'll implement your suggestion in a couple of days. Thank you!

    Daniel


    "Steven Cheng[MSFT]" <> schrieb im Newsbeitrag
    news:...
    > Hi Daniel,
    >
    > I'm viewing this post and find it is a duplicated one with another thread
    > with same title in
    > Newsgroups: microsoft.public.dotnet.framework.aspnet
    >
    > I've posted a reply and provided my suggestoins in that one. I'd

    appreciate
    > if you'd have a look there. Also, if you feel it convenient that we
    > continue to discuss in that thread, please feel free to followup there.
    > Thanks.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    >
     
    Daniel Walzenbach, Jun 3, 2004
    #5
    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. Daniel Walzenbach
    Replies:
    2
    Views:
    8,732
    Steven Cheng[MSFT]
    Jun 2, 2004
  2. =?Utf-8?B?am9obm55Rw==?=

    Can you identify the cell clicked in an ASP.NET datagrid?

    =?Utf-8?B?am9obm55Rw==?=, Mar 17, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,184
    =?Utf-8?B?am9obm55Rw==?=
    Mar 17, 2006
  3. Jim Mitchell

    How to determine which control in a template column was clicked...

    Jim Mitchell, Jul 28, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    139
    Joel .NET
    Oct 29, 2003
  4. Mrinalini Pande

    Find which Cell is clicked by user in GridView control of Asp.net

    Mrinalini Pande, Nov 23, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    786
    Mrinalini Pande
    Nov 23, 2006
  5. Samuel
    Replies:
    6
    Views:
    245
    Steven Cheng[MSFT]
    Jul 28, 2005
Loading...

Share This Page