DataGrid item dropdownlist javascript disable

Discussion in 'ASP .Net Web Controls' started by bnlockwood@gmail.com, Apr 2, 2006.

  1. Guest

    Hello all,.
    I have a datagrid and one of the columns has a static dropdownlist
    which means each column has the exact same dropdownlist. On the c#
    side values are pulled from the database and depending on the value
    from the db it should either keep the dropdownlist enabled or it should
    set it as disabled for that row. I believe some javascript like
    document.getElementById would help somehow but I'm still learning.

    Eg.
    Each row has a color list of:

    BROWN
    BLUE
    ORANGE

    if the database says that the row value is null then disable & hide
    that column for that row. Meaning that item doesn't need a color.

    If someone could help that would be great. Thanks in advance.
     
    , Apr 2, 2006
    #1
    1. Advertising

  2. You do not need JavaScript. This is all server-side processing since you
    have to decide based on the data.

    You can use the databinding expression to evaluate the field; if it is not
    DBNull then set the Enabled property to true otherwise false, e.g. the
    syntax in asp.net 2.0 is:

    <asp:DropDownList ID="ddlProducts" runat="server"
    Enabled='<%#Eval("Color") <> DBNull.Value%>' >
    <asp:ListItem Value="BLUE">Blue</asp:ListItem>
    <asp:ListItem Value="BROWN">Brown</asp:ListItem>
    <asp:ListItem Value="ORANGE">Orange</asp:ListItem>
    </asp:DropDownList>

    In ASP.NET 1.1:

    Enabled ='<%# DataBinder.Eval(Container.DataItem, "Color") <>
    DBNull.Value%>'
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "" wrote:

    > Hello all,.
    > I have a datagrid and one of the columns has a static dropdownlist
    > which means each column has the exact same dropdownlist. On the c#
    > side values are pulled from the database and depending on the value
    > from the db it should either keep the dropdownlist enabled or it should
    > set it as disabled for that row. I believe some javascript like
    > document.getElementById would help somehow but I'm still learning.
    >
    > Eg.
    > Each row has a color list of:
    >
    > BROWN
    > BLUE
    > ORANGE
    >
    > if the database says that the row value is null then disable & hide
    > that column for that row. Meaning that item doesn't need a color.
    >
    > If someone could help that would be great. Thanks in advance.
    >
    >
     
    Phillip Williams, Apr 2, 2006
    #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.
Similar Threads
  1. =?Utf-8?B?QXVkcmV5?=
    Replies:
    2
    Views:
    409
    =?Utf-8?B?QXVkcmV5?=
    Feb 6, 2004
  2. Joe Fallon
    Replies:
    2
    Views:
    28,584
    Joe Fallon
    Jun 1, 2005
  3. =?Utf-8?B?Z2xlbm4=?=

    Adding dummy item to DropDownList in a DataGrid

    =?Utf-8?B?Z2xlbm4=?=, Apr 25, 2006, in forum: ASP .Net
    Replies:
    15
    Views:
    789
    Scott R
    May 8, 2006
  4. Replies:
    0
    Views:
    359
  5. QUASAR
    Replies:
    6
    Views:
    424
    QUASAR
    Jan 17, 2004
Loading...

Share This Page