Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > DataGrid item dropdownlist javascript disable

Reply
Thread Tools

DataGrid item dropdownlist javascript disable

 
 
bnlockwood@gmail.com
Guest
Posts: n/a
 
      04-02-2006
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.

 
Reply With Quote
 
 
 
 
Phillip Williams
Guest
Posts: n/a
 
      04-02-2006
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:

<aspropDownList 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>
</aspropDownList>

In ASP.NET 1.1:

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


"(E-Mail Removed)" 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.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert into DataGrid from DropDownList item selection myselfgautam.kumar@gmail.com ASP .Net 0 11-15-2007 04:47 AM
Adding dummy item to DropDownList in a DataGrid =?Utf-8?B?Z2xlbm4=?= ASP .Net 15 05-08-2006 10:05 PM
insert item to dropdownlist using javascript Joe Fallon ASP .Net 2 06-01-2005 02:38 AM
setting the default item on a dropdownlist inside a datagrid =?Utf-8?B?QXVkcmV5?= ASP .Net 2 02-06-2004 04:41 AM
Change style of a single row of the item list of datagrid, based on a field value of current item... QUASAR ASP .Net Datagrid Control 6 01-17-2004 07:46 PM



Advertisments