__dopostback only does what I want after row 8

Discussion in 'ASP .Net' started by Arch, Dec 5, 2009.

  1. Arch

    Arch Guest

    I want my datagrid rows to be clickable, so that a button column is
    fired when my user clicks anywhere on a row. Using Google, I figured out
    how to do it, but it only works after row 8. From row 9 on, the next
    page opens properly, but clicking rows 1 through 8 does nothing - the
    dopostback fires, but the page does not change. If I remove this code,
    the button column works fine. This sub seems to be disabling rows 1-8
    for some reason.

    Here's my sub:

    Protected Sub DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs)
    e.Item.Attributes.Add("onclick",
    "javascript:__doPostBack('dgrDataGrid$ctl" & _
    (e.Item.ItemIndex + 2) & _
    "$ctl00','')")
    end sub

    I don't even know how to Google this problem. Can anyone tell me why
    this code should kill the functionality of my button column on the first
    few rows?

    As always, thanks.
     
    Arch, Dec 5, 2009
    #1
    1. Advertisements

  2. Arch

    Arch Guest

    Figured it out. Life is good.


    Arch wrote:
    > I want my datagrid rows to be clickable, so that a button column is
    > fired when my user clicks anywhere on a row. Using Google, I figured out
    > how to do it, but it only works after row 8. From row 9 on, the next
    > page opens properly, but clicking rows 1 through 8 does nothing - the
    > dopostback fires, but the page does not change. If I remove this code,
    > the button column works fine. This sub seems to be disabling rows 1-8
    > for some reason.
    >
    > Here's my sub:
    >
    > Protected Sub DataGrid_ItemCreated(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridItemEventArgs)
    > e.Item.Attributes.Add("onclick",
    > "javascript:__doPostBack('dgrDataGrid$ctl" & _
    > (e.Item.ItemIndex + 2) & _
    > "$ctl00','')")
    > end sub
    >
    > I don't even know how to Google this problem. Can anyone tell me why
    > this code should kill the functionality of my button column on the first
    > few rows?
    >
    > As always, thanks.
     
    Arch, Dec 6, 2009
    #2
    1. Advertisements

  3. Arch

    leonidmk

    Joined:
    Aug 12, 2012
    Messages:
    2
    Likes Received:
    0
    Hi Arch,

    I have exactly the same problem as you had.
    My click event of DataGrid does not work from the first row.
    I spend all day to find out what the problem is. Unfortunately no success.

    Can you please let me know what the problem was in your case?

    Thank you,

    Leon
     
    leonidmk, Aug 12, 2012
    #3
    1. Advertisements

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. Luis Esteban Valencia

    Make a DataGrid row editable after user selects the row

    Luis Esteban Valencia, Jan 12, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    450
    Luis Esteban Valencia
    Jan 12, 2005
  2. Luis Esteban Valencia

    My addnew row button is only adding one row?

    Luis Esteban Valencia, Mar 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,051
    Luis Esteban Valencia
    Mar 23, 2005
  3. H5N1
    Replies:
    0
    Views:
    2,978
  4. Jason
    Replies:
    1
    Views:
    2,807
    Alexey Smirnov
    Dec 14, 2009
  5. Want to add row under selected row of gridview

    , Feb 16, 2007, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    470
  6. troutbum

    Cannot Find Row Index after using row filter

    troutbum, Jan 22, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    10
    Views:
    713
    Andre
    Feb 19, 2004
  7. D
    Replies:
    0
    Views:
    495
  8. Selected Row Only GridView Row Visible?

    , Oct 17, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    446
Loading...