How can I disable a Delete button Based on Condition

Discussion in 'ASP .Net Datagrid Control' started by Paul D. Fox, Jun 10, 2005.

  1. Paul D. Fox

    Paul D. Fox Guest

    I have a Datagrid displaying "Start Date" and "End Date" with a Delete
    Button. I want to disable the Delete Button if the Start Date is less than
    current date. I believe you do this in the "DataGrid1_ItemDataBound" but
    not sure what to code here.

    Paul
    Paul D. Fox, Jun 10, 2005
    #1
    1. Advertising

  2. Paul D. Fox

    Brock Allen Guest

    In the ItemDataBound use FindControl("TheIDOfTheButton") to get access the
    the Control. Once you have the control, you can set the Enabled property.
    You'll have to call FindControl on the DataGridItemEventArgs.Item, which
    is the row in the DataGrid that was just DataBound.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > I have a Datagrid displaying "Start Date" and "End Date" with a Delete
    > Button. I want to disable the Delete Button if the Start Date is less
    > than current date. I believe you do this in the
    > "DataGrid1_ItemDataBound" but not sure what to code here.
    >
    > Paul
    >
    Brock Allen, Jun 10, 2005
    #2
    1. Advertising

  3. Paul D. Fox

    John Guest

    Hey I'm having a similar problem. I need to deactivate a control on my
    datagrid based on the results of an sql query. i cant figure out a a good
    place or way to loop through the results of the query and disable the
    control. there are 3 kinds of PINs bieng boudn to the data grid.
    Deactivated Masters, Deactivated sub pins with active masters and deactivated
    subs without active masters. i need to be able to look through the lists of
    pins and determine what catagory they fall into(i have a sql statement for
    this) and if i find an deactivated sub with a deactivated master i want to
    disable the activate button so we dont activate a pin that we cant see or
    use(beacuse the managemnt grid is controlled by master pins). any help
    would be appreciated. the only place i can think of is to use an
    OnItemDataBound method but that seems like it could take awhile and i'm not
    sure how to step through the information in my SqlDataReader to test for my
    cases
    John, Jun 14, 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. -
    Replies:
    12
    Views:
    677
    Remon van Vliet
    Jun 15, 2005
  2. keithb
    Replies:
    3
    Views:
    34,071
    pianocomposer
    Dec 12, 2008
  3. avrootshell
    Replies:
    0
    Views:
    344
    avrootshell
    Mar 13, 2007
  4. Simon Abolnar

    Disable button in datagird on condition

    Simon Abolnar, Mar 1, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    160
    Elton Wang
    Mar 1, 2005
  5. Bill W.
    Replies:
    13
    Views:
    281
    Phillip Gawlowski
    May 9, 2011
Loading...

Share This Page