Results 1 to 6 of 6

Thread: Disable button column in datagrid

  1. #1

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    Disable button column in datagrid

    I need to do this based on certain conditions, does anyone know how please?

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Disable button column in datagrid

    I have done something similar in C#. Will do?

    PHP Code:

                                    DropDownList ddl 
    = (DropDownList)sender;
                    
    string strLeaveType ddl.SelectedValue.ToString();
    //strLeaveType will be my condition in the switch statement.

    DataGridItemCollection DataGridItems dgEditLeave.Items;
                    for (
    counter=0counter<DataGridItems.Countcounter++) 
                    {
                        
    DropDownList ddl1 = (DropDownList)DataGridItems[counter].FindControl("cmbLeaveType");
                        if(
    ddl1 != null)
                        {
                            if (
    ddl.ClientID ==  ddl1.ClientID)
                                break;
                        }
                    }

    //Basically, I'm looking for a dropdown.  I want to read the value in the dropdown and based upon that, I do certain things. 

    TextBox txtC = (TextBox)dgEditLeave.Items[counter].FindControl("txtComments");

    //Now, I have "gotten" a textbox that I want to work with.

    switch(strLeaveType)
                    {
                        case 
    "CompensatoryOff":
                            
    txtC.Enabled=true;
                            break;
    //and on and on.... 
    While the second part of the code wouldn't be relevant, the first part is what's most important. You gain access to the controls in the datagrid. You can loop through and disable it, so on and so forth.

    If you're doing this in the ItemDataBound event, then you'll be working with e.

    HTH. If not, ask questions. It took me a while to understand this myself.

  3. #3

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    Re: Disable button column in datagrid

    I sorta understand, at what point do I disable the control, from within the loop, i cant find the property to do it.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Disable button column in datagrid

    As soon as you've assigned the button object, you can disable it.

  5. #5

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    Re: Disable button column in datagrid

    cheers, i did it this way in the end.

    VB Code:
    1. If dvResults.Count <= dgSummary.PageSize Then
    2.                 strTicker = dvResults.Count
    3.             End If
    4.  
    5.             If dvResults.Count > dgSummary.PageSize Then
    6.                 If dgSummary.CurrentPageIndex < dgSummary.PageCount - 1 Then
    7.                     strTicker = dgSummary.PageSize
    8.                 Else
    9.                     strTicker = (dvResults.Count Mod dgSummary.PageCount)
    10.                 End If
    11.             End If
    12.             strTicker = strTicker - 1
    13.  
    14.             For z = 0 To strTicker
    15.                 strAccount1 = wibble.Item(z).Cells(0).Controls(0)
    16.                 straccount2 = strAccount1.Text
    17.                 wibble.Item(z).Cells(0).Controls(0).Visible = False
    18.                 wibble.Item(z).Cells(0).Text = straccount2
    19.             Next
    20.         End If

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Disable button column in datagrid

    Not sure what half of that is, especially the "wibble" . But as long as it works, it's good.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width