dopostback problem with datagrids

Discussion in 'ASP .Net Web Controls' started by Arch, Dec 6, 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 6, 2009
    #1
    1. Advertising

  2. Arch

    Arch Guest

    Never mind, 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. 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. Timothy Kelley

    calling doPostBack not working

    Timothy Kelley, Jul 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    740
  2. Johno

    doPostBack client-side function

    Johno, Jul 18, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    7,760
    Johno
    Jul 21, 2003
  3. Alfonso Alvarez
    Replies:
    2
    Views:
    659
    Alfonso Alvarez
    May 13, 2004
  4. Rob Meade

    LinkButton / doPostBack problem

    Rob Meade, Aug 25, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    4,032
    Raterus
    Aug 25, 2004
  5. Marko Vuksanovic

    Problem with FileUpload control and doPostback

    Marko Vuksanovic, Jun 30, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    7,513
    =?Utf-8?B?c2FyYQ==?=
    Jul 2, 2006
Loading...

Share This Page