ButtonColumn in a DataGrid

Discussion in 'ASP .Net' started by jmclej@hotmail.com, Oct 11, 2005.

  1. Guest

    Hi,

    I would like to use a buttoncolumn in my datagrid. But I don't want to
    enable the click on it on all the rows. I want to enable the button
    according to the data specified in another column. First of all is it
    possible to do so, and if yes, how can it be done?
    Thanks for your help.
    JULIEN
     
    , Oct 11, 2005
    #1
    1. Advertising

  2. Yes it can be done.

    1) Handle the ItemDataBound event, 2) check for the condition, 3) locate the
    button within the item handled by the event, 4) disable the button.

    This sample http://www.societopia.net/samples/dataGrid_5c.aspx handles the
    ItemDataBound, and changes the attributes of a buttonColumn of type
    LinkButton.

    To disable the button you can either replace it with a simple literal
    control upon DataBinding or change its onClick event to alert the user (using
    JavaScript) that no action is available for this selection.
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "" wrote:

    > Hi,
    >
    > I would like to use a buttoncolumn in my datagrid. But I don't want to
    > enable the click on it on all the rows. I want to enable the button
    > according to the data specified in another column. First of all is it
    > possible to do so, and if yes, how can it be done?
    > Thanks for your help.
    > JULIEN
    >
    >
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Oct 11, 2005
    #2
    1. Advertising

  3. Button1.Attributes.Add("OnClick", "JavaScript: return(false);") should also
    disable the button. I did not check this code through.

    Trevor Benedict R

    "Phillip Williams" <> wrote in message
    news:...
    > Yes it can be done.
    >
    > 1) Handle the ItemDataBound event, 2) check for the condition, 3) locate
    > the
    > button within the item handled by the event, 4) disable the button.
    >
    > This sample http://www.societopia.net/samples/dataGrid_5c.aspx handles the
    > ItemDataBound, and changes the attributes of a buttonColumn of type
    > LinkButton.
    >
    > To disable the button you can either replace it with a simple literal
    > control upon DataBinding or change its onClick event to alert the user
    > (using
    > JavaScript) that no action is available for this selection.
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "" wrote:
    >
    >> Hi,
    >>
    >> I would like to use a buttoncolumn in my datagrid. But I don't want to
    >> enable the click on it on all the rows. I want to enable the button
    >> according to the data specified in another column. First of all is it
    >> possible to do so, and if yes, how can it be done?
    >> Thanks for your help.
    >> JULIEN
    >>
    >>
     
    Trevor Benedict R, Oct 12, 2005
    #3
    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. Northern
    Replies:
    0
    Views:
    413
    Northern
    Jul 22, 2003
  2. CGuy
    Replies:
    2
    Views:
    2,038
  3. John
    Replies:
    3
    Views:
    3,262
    Giorgio Parmeggiani
    Nov 3, 2003
  4. RSB
    Replies:
    6
    Views:
    7,754
    Karim
    May 19, 2004
  5. z. f.
    Replies:
    4
    Views:
    1,370
    z. f.
    Jun 23, 2004
Loading...

Share This Page