|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataGrid item dropdownlist javascript disableI 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. 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%>' Show quoteHide quote "bnlockw***@gmail.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. > >
Fitting a table inside an ASP Panel
checkbox bind with 0 = checked? error using .NET CrystalReportViewer (.NET 1.1 VS.NET 2003) Removing columns from Gridview(2.0) databinding on templatefileds dont work? Gridview PostBack Problems GridView Height InputAttributes in RowCreated (gridview) WebControl rendering in frontpage 2003 - Migrating from Visual Studio 2003 to 2005 GridView XmlDataSource Enabling/Disabling a Tab in a TabStrip |
|||||||||||||||||||||||