Button Field in Grdview control

Discussion in 'ASP .Net Datagrid Control' started by BW, Mar 5, 2007.

  1. BW

    BW Guest

    I am a newbie to ASP.NET and have a question about a button field I have
    added to a gridview. When you click on the button I want to update a
    label with the value from a datakey. the issue I have with this is that by
    clicking the button it isn'tchange the selected index of the gridview. How
    do I set the selected index to the current row?

    Thanks
    BW
    BW, Mar 5, 2007
    #1
    1. Advertising

  2. BW

    Teemu Keiski Guest

    Hi,

    set CommandName="Select" to the ButtonField. You'll get the index of the row
    automagically in RowCommand via e.CommandArgument (even when you'd use other
    command name than Select as long as RowCommand runs)

    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net


    "BW" <> wrote in message
    news:...
    >I am a newbie to ASP.NET and have a question about a button field I have
    >added to a gridview. When you click on the button I want to update a
    >label with the value from a datakey. the issue I have with this is that
    >by clicking the button it isn'tchange the selected index of the gridview.
    >How do I set the selected index to the current row?
    >
    > Thanks
    > BW
    >
    Teemu Keiski, Mar 8, 2007
    #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.

Share This Page