Select button in datagrid

Discussion in 'ASP .Net Datagrid Control' started by Jeronimo Bertran, Feb 24, 2005.

  1. I have created a datagrid with a select button so that a user can select a
    particular row. I did this by setting the CommandName="select". And
    everything works fine. I now want to a add a second button that first
    selects the row clicked and then performs a second task with that row.

    How can I achieve this?

    Thanks,

    Jeronimo Bertran
     
    Jeronimo Bertran, Feb 24, 2005
    #1
    1. Advertisements

  2. Hi Jeronimo,

    Welcome to MSDN newsgroup. From your description, you want to add a custom
    button column in a webform datagrid. When the user click that button, that
    certain row will turn into select mode and also perform
    some other operate, yes?

    Would you provide some further description on the "a second task"? Is it a
    serverside task or a clientside task? If a serverside task, is it possbile
    that we perform it just in the DataGrid's ItemCommand event when fired by
    the button clicked event?

    Please feel free to let me know if you have any certain concern on this.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Feb 24, 2005
    #2
    1. Advertisements

  3. Hi Steven,

    The additional task is a server side task. But it is a different task that
    the one performed when the select button is pressed.

    Thanks


    (Steven Cheng[MSFT]) wrote in
     
    Jeronimo Bertran, Feb 24, 2005
    #3
  4. Hi Jeronimo,

    Thanks for your followup. Then, since the task the second button to do is a
    serverside task, is it ok that we provide a helper function to do the work
    and put the function in the ItemCommand event of the datagrid?
    All the postback event raise by buttons(or other submit controls) in
    datagridrow will fire the DataGrid's
    ItemCommand event.

    Thanks,


    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Feb 25, 2005
    #4
  5. However, even if we use the ItemCommand Event, the clicked row is not
    selected on the datagrid. I want to have the row selected and then perform
    the additional task.


    (Steven Cheng[MSFT]) wrote in
     
    Jeronimo Bertran, Feb 26, 2005
    #5
  6. Thanks for your reply Jeronimo,

    AS for selecting a row, we need to set the SelectItemIndex and them rebind
    the grid with the datasource. So when we want to both select a certain row
    and perform some further operations, we should also rebind the grid with
    the datasource(just like in SelectCommand) and then do that additional
    task.
    In addition, do you think it's possible that we register some client script
    in the ItemCommand which used to post back the form again to do the
    additional task? That means in the first post back(itemcommend) , we do row
    selection, and in the second postback, we do the further task?

    Thanks,


    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Feb 28, 2005
    #6
  7. Steven,

    Yes, we could register a client script for the ItemCommand... would the
    commandName be "select" for this button as well? Could you elaborate on
    that idea?

    Thanks

    (Steven Cheng[MSFT]) wrote in
     
    Jeronimo Bertran, Mar 2, 2005
    #7
  8. Hi Jeronimo,

    Thanks for your followup. Yes, the commandName could be the same as the
    "Select" button, but why would you do so since it'll make it
    undistinguishable from the select button?
    What I means in the last message is to put a button column in the
    datagrid, the commandName of the button be set to another value rather than
    the "Select" , then when the button is clicked, the page is posteback and
    in the ItemCommand event, we register a script block which will post back
    the page again , so that we can do the additional works. (such as
    document.forms[0].submit()) or call the auto generated __doPostBack)

    How do you think of this?

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Mar 3, 2005
    #8
  9. (Steven Cheng[MSFT]) wrote in



    Thanks Steven, I will give it a try.
     
    Jeronimo Bertran, Mar 3, 2005
    #9
  10. You're welcome.

    If there is any further questions, please feel free to post here.
    Good Luck!

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Mar 4, 2005
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.