RE: fire event when click on specific cell in dataGrid using asp.net

Discussion in 'ASP .Net' started by =?Utf-8?B?YW5nc3JhbQ==?=, Jul 28, 2004.

  1. In order to add click event to the entire row of datagrid, add a link button as a hidden column to the datagrid and then in ItemDataBound event of datagrid, we can attribute the link click event to the entire row in the following way :
    //Get the link button
    LinkButton lnkButton = (LinkButton)grdEventArgs.Item.Cells[0].Controls[0];

    // add the click event to the entire list item
    grdEventArgs.Item.Attributes["onclick"] = Page.GetPostBackClientHyperlink(lnkButton, "");

    thats it..when the user clicks on the row, the row is selected and SelectedIndex event is fired which we can catch in the code behind and get the SelectedIndex value.
    hope this answers you.
     
    =?Utf-8?B?YW5nc3JhbQ==?=, Jul 28, 2004
    #1
    1. Advertising

  2. RE: fire event when click on specific cell in dataGrid using asp.n

    pleaze tell me how we can use selectedindexchange event. because i am using nested grid. when i click on child datagrid then that row is selected. the selectedindexchange event also fired. but problem is how i get the specific cell value.where i click in child dataGrid. because the event arguments has two methods. empty and gettype. plz help me out.

    "angsram" wrote:

    > In order to add click event to the entire row of datagrid, add a link button as a hidden column to the datagrid and then in ItemDataBound event of datagrid, we can attribute the link click event to the entire row in the following way :
    > //Get the link button
    > LinkButton lnkButton = (LinkButton)grdEventArgs.Item.Cells[0].Controls[0];
    >
    > // add the click event to the entire list item
    > grdEventArgs.Item.Attributes["onclick"] = Page.GetPostBackClientHyperlink(lnkButton, "");
    >
    > thats it..when the user clicks on the row, the row is selected and SelectedIndex event is fired which we can catch in the code behind and get the SelectedIndex value.
    > hope this answers you.
    >
     
    =?Utf-8?B?dGVuemVlbC4=?=, Jul 31, 2004
    #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. Cory D.
    Replies:
    1
    Views:
    679
    =?Utf-8?B?dGVuemVlbC4=?=
    Jul 28, 2004
  2. John Saunders
    Replies:
    0
    Views:
    410
    John Saunders
    Jul 27, 2004
  3. Eliyahu Goldin
    Replies:
    1
    Views:
    529
    =?Utf-8?B?dGVuemVlbC4=?=
    Jul 31, 2004
  4. =?Utf-8?B?dGVuemVlbC4=?=

    Fire event when clicking on the specific cell

    =?Utf-8?B?dGVuemVlbC4=?=, Jul 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    420
    =?Utf-8?B?YW5nc3JhbQ==?=
    Jul 28, 2004
  5. Amy
    Replies:
    0
    Views:
    992
Loading...

Share This Page