473,837 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add items to a dropdownlist control within a Javascript eventhandler?

I want to add items to a dropdownlist control within a Javascript
eventhandler.
This is what I code :

var dd = document.getEle mentById("DropD ownList1");

dd.Items.Add("1 990");
dd.Items.Add("1 991");
dd.Items.Add("1 992");

however, it doesn't work.

What should I code instead ?
Nov 19 '05 #1
6 16623
Oscar,

try the following:

document.getEle mentById("DropD ownList").optio ns[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.n l> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I want to add items to a dropdownlist control within a Javascript
eventhandler .
This is what I code :

var dd = document.getEle mentById("DropD ownList1");

dd.Items.Add("1 990");
dd.Items.Add("1 991");
dd.Items.Add("1 992");

however, it doesn't work.

What should I code instead ?

Nov 19 '05 #2
Daniel,
thanks for the advice. This solution works in case the DropDownList is
positioned free within a page.
However, In my case it is part of a Webgrid, as part of the NetAdvantage Web
Controls and within this configuration, it doesn't work.
I've attached a part of the HTML. Maybe you can find the origin of the
problem.

regards,
Oscar

<igtbl:ultraweb grid id="UltraWebGri d1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayou t RowHeightDefaul t="20px" Version="4.00"
BorderCollapseD efault="Separat e" Name="UltraWebG rid1">
<AddNewBox>
<Style BorderWidth="1p x" BorderStyle="So lid" BackColor="Ligh tGray">

<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1p x" BorderStyle="So lid" BackColor="Ligh tGray">

<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDef ault BorderStyle="So lid" BackColor="Ligh tGray">
<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e"></BorderDetails>
</HeaderStyleDefa ult>
<FrameStyle Width="325px" BorderWidth="1p x" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="So lid"
Height="200px"> </FrameStyle>
<FooterStyleDef ault BorderWidth="1p x" BorderStyle="So lid"
BackColor="Ligh tGray">
<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e"></BorderDetails>
</FooterStyleDefa ult>
<ClientSideEven ts
BeforeRowTempla teOpenHandler=" UltraWebGrid1_B eforeRowTemplat eOpenHandler"
AfterRowTemplat eOpenHandler="U ltraWebGrid1_Af terRowTemplateO penHandler"></ClientSideEvent s>
<EditCellStyleD efault BorderWidth="0p x"
BorderStyle="No ne"></EditCellStyleDe fault>
<RowStyleDefaul t BorderWidth="1p x" BorderColor="Gr ay"
BorderStyle="So lid">
<Padding Left="3px"></Padding>
<BorderDetail s WidthLeft="0px" WidthTop="0px"> </BorderDetails>
</RowStyleDefault >
</DisplayLayout>
<Bands>
<igtbl:UltraGri dBand AllowUpdate="Ro wTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGri dColumn HeaderText="naa m" Key="naam"
BaseColumnName= "">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"> </Header>
</igtbl:UltraGrid Column>
<igtbl:UltraGri dColumn HeaderText="kle ur" Key="kleur"
Type="DropDownL ist" BaseColumnName= "">
<ValueList>
<ValueListItems >
<igtbl:ValueLis tItem DataValue="geel " Key="geel"
DisplayText="ge el"></igtbl:ValueList Item>
<igtbl:ValueLis tItem DataValue="rood " Key="rood"
DisplayText="ro od"></igtbl:ValueList Item>
<igtbl:ValueLis tItem DataValue="blau w" Key="blauw"
DisplayText="bl auw"></igtbl:ValueList Item>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur" ></Header>
</igtbl:UltraGrid Column>
</Columns>
<RowEditTemplat e>
<DIV style="WIDTH: 256px; POSITION: relative; HEIGHT: 104px"
ms_positioning= "GridLayout ">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 16px" runat="server"> naam</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 16px; POSITION:
absolute; TOP: 56px" runat="server"> kleur</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 72px;
POSITION: absolute; TOP: 16px" runat="server"
columnKey="naam "></asp:TextBox>
<asp:DropDownLi st id="DropDownLis t1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleu r"></asp:DropDownLis t></DIV>
<BR>
<P align="center"> <INPUT id="igtbl_reOkB tn" style="WIDTH: 50px"
onclick="igtbl_ gRowEditButtonC lick(event);"
type="button" value="OK">&nbs p; <INPUT id="igtbl_reCan celBtn"
style="WIDTH: 50px" onclick="igtbl_ gRowEditButtonC lick(event);"
type="button" value="Cancel"> </P>
</RowEditTemplate >
<RowTemplateSty le BorderColor="Wh ite" BorderStyle="Ri dge"
BackColor="Whit e">
<BorderDetail s WidthLeft="3px" WidthTop="3px" WidthRight="3px "
WidthBottom="3p x"></BorderDetails>
</RowTemplateStyl e>
</igtbl:UltraGrid Band>
</Bands>
</igtbl:ultrawebg rid>


"Daniel Walzenbach" <da************ ***@newsgroup.n ospam> schreef in bericht
news:eo******** ******@TK2MSFTN GP12.phx.gbl...
Oscar,

try the following:

document.getEle mentById("DropD ownList").optio ns[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.n l> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I want to add items to a dropdownlist control within a Javascript
eventhandle r.
This is what I code :

var dd = document.getEle mentById("DropD ownList1");

dd.Items.Add("1 990");
dd.Items.Add("1 991");
dd.Items.Add("1 992");

however, it doesn't work.

What should I code instead ?


Nov 19 '05 #3
Oscar,

did you check what will be rendered on your page. Do a "View Source" of the
page and check out the naming pattern.

Does this help?

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.n l> schrieb im Newsbeitrag
news:ua******** ********@TK2MSF TNGP15.phx.gbl. ..
Daniel,
thanks for the advice. This solution works in case the DropDownList is
positioned free within a page.
However, In my case it is part of a Webgrid, as part of the NetAdvantage
Web Controls and within this configuration, it doesn't work.
I've attached a part of the HTML. Maybe you can find the origin of the
problem.

regards,
Oscar

<igtbl:ultraweb grid id="UltraWebGri d1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayou t RowHeightDefaul t="20px" Version="4.00"
BorderCollapseD efault="Separat e" Name="UltraWebG rid1">
<AddNewBox>
<Style BorderWidth="1p x" BorderStyle="So lid" BackColor="Ligh tGray">

<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1p x" BorderStyle="So lid" BackColor="Ligh tGray">

<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDef ault BorderStyle="So lid" BackColor="Ligh tGray">
<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e"></BorderDetails>
</HeaderStyleDefa ult>
<FrameStyle Width="325px" BorderWidth="1p x" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="So lid"
Height="200px"> </FrameStyle>
<FooterStyleDef ault BorderWidth="1p x" BorderStyle="So lid"
BackColor="Ligh tGray">
<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e"></BorderDetails>
</FooterStyleDefa ult>
<ClientSideEven ts
BeforeRowTempla teOpenHandler=" UltraWebGrid1_B eforeRowTemplat eOpenHandler"
AfterRowTemplat eOpenHandler="U ltraWebGrid1_Af terRowTemplateO penHandler"></ClientSideEvent s>
<EditCellStyleD efault BorderWidth="0p x"
BorderStyle="No ne"></EditCellStyleDe fault>
<RowStyleDefaul t BorderWidth="1p x" BorderColor="Gr ay"
BorderStyle="So lid">
<Padding Left="3px"></Padding>
<BorderDetail s WidthLeft="0px" WidthTop="0px"> </BorderDetails>
</RowStyleDefault >
</DisplayLayout>
<Bands>
<igtbl:UltraGri dBand AllowUpdate="Ro wTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGri dColumn HeaderText="naa m" Key="naam"
BaseColumnName= "">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"> </Header>
</igtbl:UltraGrid Column>
<igtbl:UltraGri dColumn HeaderText="kle ur" Key="kleur"
Type="DropDownL ist" BaseColumnName= "">
<ValueList>
<ValueListItems >
<igtbl:ValueLis tItem DataValue="geel " Key="geel"
DisplayText="ge el"></igtbl:ValueList Item>
<igtbl:ValueLis tItem DataValue="rood " Key="rood"
DisplayText="ro od"></igtbl:ValueList Item>
<igtbl:ValueLis tItem DataValue="blau w" Key="blauw"
DisplayText="bl auw"></igtbl:ValueList Item>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur" ></Header>
</igtbl:UltraGrid Column>
</Columns>
<RowEditTemplat e>
<DIV style="WIDTH: 256px; POSITION: relative; HEIGHT: 104px"
ms_positioning= "GridLayout ">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 16px" runat="server"> naam</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 16px; POSITION:
absolute; TOP: 56px" runat="server"> kleur</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 72px;
POSITION: absolute; TOP: 16px" runat="server"
columnKey="naam "></asp:TextBox>
<asp:DropDownLi st id="DropDownLis t1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleu r"></asp:DropDownLis t></DIV>
<BR>
<P align="center"> <INPUT id="igtbl_reOkB tn" style="WIDTH: 50px"
onclick="igtbl_ gRowEditButtonC lick(event);"
type="button" value="OK">&nbs p; <INPUT id="igtbl_reCan celBtn"
style="WIDTH: 50px" onclick="igtbl_ gRowEditButtonC lick(event);"
type="button" value="Cancel"> </P>
</RowEditTemplate >
<RowTemplateSty le BorderColor="Wh ite" BorderStyle="Ri dge"
BackColor="Whit e">
<BorderDetail s WidthLeft="3px" WidthTop="3px" WidthRight="3px "
WidthBottom="3p x"></BorderDetails>
</RowTemplateStyl e>
</igtbl:UltraGrid Band>
</Bands>
</igtbl:ultrawebg rid>


"Daniel Walzenbach" <da************ ***@newsgroup.n ospam> schreef in
bericht news:eo******** ******@TK2MSFTN GP12.phx.gbl...
Oscar,

try the following:

document.getEle mentById("DropD ownList").optio ns[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.n l> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I want to add items to a dropdownlist control within a Javascript
eventhandler .
This is what I code :

var dd = document.getEle mentById("DropD ownList1");

dd.Items.Add("1 990");
dd.Items.Add("1 991");
dd.Items.Add("1 992");

however, it doesn't work.

What should I code instead ?



Nov 19 '05 #4
Daniel,

You are a hero to me! I've done the view source and I saw that the ID was
rewritten as ID= UltraWebGrid1__ ctl0_DropDownLi st1. I've changed the HTML
source to

document.getEle mentById("Ultra WebGrid1__ctl0_ DropDownList1") .options[0] =
new Option("1990", "1990");

and now it's working!

thank you very much and have a nice day.

regards,
Oscar
"Daniel Walzenbach" <da************ ***@newsgroup.n ospam> schreef in bericht
news:u0******** ******@TK2MSFTN GP14.phx.gbl...
Oscar,

did you check what will be rendered on your page. Do a "View Source" of
the page and check out the naming pattern.

Does this help?

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.n l> schrieb im Newsbeitrag
news:ua******** ********@TK2MSF TNGP15.phx.gbl. ..
Daniel,
thanks for the advice. This solution works in case the DropDownList is
positioned free within a page.
However, In my case it is part of a Webgrid, as part of the NetAdvantage
Web Controls and within this configuration, it doesn't work.
I've attached a part of the HTML. Maybe you can find the origin of the
problem.

regards,
Oscar

<igtbl:ultraweb grid id="UltraWebGri d1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayou t RowHeightDefaul t="20px" Version="4.00"
BorderCollapseD efault="Separat e" Name="UltraWebG rid1">
<AddNewBox>
<Style BorderWidth="1p x" BorderStyle="So lid" BackColor="Ligh tGray">

<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1p x" BorderStyle="So lid" BackColor="Ligh tGray">

<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDef ault BorderStyle="So lid" BackColor="Ligh tGray">
<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e"></BorderDetails>
</HeaderStyleDefa ult>
<FrameStyle Width="325px" BorderWidth="1p x" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="So lid"
Height="200px"> </FrameStyle>
<FooterStyleDef ault BorderWidth="1p x" BorderStyle="So lid"
BackColor="Ligh tGray">
<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e"></BorderDetails>
</FooterStyleDefa ult>
<ClientSideEven ts
BeforeRowTempla teOpenHandler=" UltraWebGrid1_B eforeRowTemplat eOpenHandler"
AfterRowTemplat eOpenHandler="U ltraWebGrid1_Af terRowTemplateO penHandler"></ClientSideEvent s>
<EditCellStyleD efault BorderWidth="0p x"
BorderStyle="No ne"></EditCellStyleDe fault>
<RowStyleDefaul t BorderWidth="1p x" BorderColor="Gr ay"
BorderStyle="So lid">
<Padding Left="3px"></Padding>
<BorderDetail s WidthLeft="0px" WidthTop="0px"> </BorderDetails>
</RowStyleDefault >
</DisplayLayout>
<Bands>
<igtbl:UltraGri dBand AllowUpdate="Ro wTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGri dColumn HeaderText="naa m" Key="naam"
BaseColumnName= "">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"> </Header>
</igtbl:UltraGrid Column>
<igtbl:UltraGri dColumn HeaderText="kle ur" Key="kleur"
Type="DropDownL ist" BaseColumnName= "">
<ValueList>
<ValueListItems >
<igtbl:ValueLis tItem DataValue="geel " Key="geel"
DisplayText="ge el"></igtbl:ValueList Item>
<igtbl:ValueLis tItem DataValue="rood " Key="rood"
DisplayText="ro od"></igtbl:ValueList Item>
<igtbl:ValueLis tItem DataValue="blau w" Key="blauw"
DisplayText="bl auw"></igtbl:ValueList Item>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur" ></Header>
</igtbl:UltraGrid Column>
</Columns>
<RowEditTemplat e>
<DIV style="WIDTH: 256px; POSITION: relative; HEIGHT: 104px"
ms_positioning= "GridLayout ">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 16px" runat="server"> naam</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 16px; POSITION:
absolute; TOP: 56px" runat="server"> kleur</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 72px;
POSITION: absolute; TOP: 16px" runat="server"
columnKey="naam "></asp:TextBox>
<asp:DropDownLi st id="DropDownLis t1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleu r"></asp:DropDownLis t></DIV>
<BR>
<P align="center"> <INPUT id="igtbl_reOkB tn" style="WIDTH: 50px"
onclick="igtbl_ gRowEditButtonC lick(event);"
type="button" value="OK">&nbs p; <INPUT id="igtbl_reCan celBtn"
style="WIDTH: 50px" onclick="igtbl_ gRowEditButtonC lick(event);"
type="button" value="Cancel"> </P>
</RowEditTemplate >
<RowTemplateSty le BorderColor="Wh ite" BorderStyle="Ri dge"
BackColor="Whit e">
<BorderDetail s WidthLeft="3px" WidthTop="3px" WidthRight="3px "
WidthBottom="3p x"></BorderDetails>
</RowTemplateStyl e>
</igtbl:UltraGrid Band>
</Bands>
</igtbl:ultrawebg rid>


"Daniel Walzenbach" <da************ ***@newsgroup.n ospam> schreef in
bericht news:eo******** ******@TK2MSFTN GP12.phx.gbl...
Oscar,

try the following:

document.getEle mentById("DropD ownList").optio ns[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.n l> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I want to add items to a dropdownlist control within a Javascript
eventhandle r.
This is what I code :

var dd = document.getEle mentById("DropD ownList1");

dd.Items.Add("1 990");
dd.Items.Add("1 991");
dd.Items.Add("1 992");

however, it doesn't work.

What should I code instead ?



Nov 19 '05 #5
Thanks Oscar,

Glad I could help! What you see is basically what happens. To guarantee
uniqueness all "repeater"-controls translate the ID to a progressional. ID.
Actually the tip I gave you is helpful in a lot of scenarios. Especially if
you want to know how webcontrols are "translated ".

Take care
---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.n l> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Daniel,

You are a hero to me! I've done the view source and I saw that the ID was
rewritten as ID= UltraWebGrid1__ ctl0_DropDownLi st1. I've changed the HTML
source to

document.getEle mentById("Ultra WebGrid1__ctl0_ DropDownList1") .options[0] =
new Option("1990", "1990");

and now it's working!

thank you very much and have a nice day.

regards,
Oscar
"Daniel Walzenbach" <da************ ***@newsgroup.n ospam> schreef in
bericht news:u0******** ******@TK2MSFTN GP14.phx.gbl...
Oscar,

did you check what will be rendered on your page. Do a "View Source" of
the page and check out the naming pattern.

Does this help?

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.n l> schrieb im Newsbeitrag
news:ua******** ********@TK2MSF TNGP15.phx.gbl. ..
Daniel,
thanks for the advice. This solution works in case the DropDownList is
positioned free within a page.
However, In my case it is part of a Webgrid, as part of the NetAdvantage
Web Controls and within this configuration, it doesn't work.
I've attached a part of the HTML. Maybe you can find the origin of the
problem.

regards,
Oscar

<igtbl:ultraweb grid id="UltraWebGri d1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayou t RowHeightDefaul t="20px" Version="4.00"
BorderCollapseD efault="Separat e" Name="UltraWebG rid1">
<AddNewBox>
<Style BorderWidth="1p x" BorderStyle="So lid" BackColor="Ligh tGray">

<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1p x" BorderStyle="So lid" BackColor="Ligh tGray">

<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDef ault BorderStyle="So lid" BackColor="Ligh tGray">
<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e"></BorderDetails>
</HeaderStyleDefa ult>
<FrameStyle Width="325px" BorderWidth="1p x" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="So lid"
Height="200px"> </FrameStyle>
<FooterStyleDef ault BorderWidth="1p x" BorderStyle="So lid"
BackColor="Ligh tGray">
<BorderDetail s ColorTop="White " WidthLeft="1px" WidthTop="1px"
ColorLeft="Whit e"></BorderDetails>
</FooterStyleDefa ult>
<ClientSideEven ts
BeforeRowTempla teOpenHandler=" UltraWebGrid1_B eforeRowTemplat eOpenHandler"
AfterRowTemplat eOpenHandler="U ltraWebGrid1_Af terRowTemplateO penHandler"></ClientSideEvent s>
<EditCellStyleD efault BorderWidth="0p x"
BorderStyle="No ne"></EditCellStyleDe fault>
<RowStyleDefaul t BorderWidth="1p x" BorderColor="Gr ay"
BorderStyle="So lid">
<Padding Left="3px"></Padding>
<BorderDetail s WidthLeft="0px" WidthTop="0px"> </BorderDetails>
</RowStyleDefault >
</DisplayLayout>
<Bands>
<igtbl:UltraGri dBand AllowUpdate="Ro wTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGri dColumn HeaderText="naa m" Key="naam"
BaseColumnName= "">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"> </Header>
</igtbl:UltraGrid Column>
<igtbl:UltraGri dColumn HeaderText="kle ur" Key="kleur"
Type="DropDownL ist" BaseColumnName= "">
<ValueList>
<ValueListItems >
<igtbl:ValueLis tItem DataValue="geel " Key="geel"
DisplayText="ge el"></igtbl:ValueList Item>
<igtbl:ValueLis tItem DataValue="rood " Key="rood"
DisplayText="ro od"></igtbl:ValueList Item>
<igtbl:ValueLis tItem DataValue="blau w" Key="blauw"
DisplayText="bl auw"></igtbl:ValueList Item>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur" ></Header>
</igtbl:UltraGrid Column>
</Columns>
<RowEditTemplat e>
<DIV style="WIDTH: 256px; POSITION: relative; HEIGHT: 104px"
ms_positioning= "GridLayout ">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 16px" runat="server"> naam</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 16px; POSITION:
absolute; TOP: 56px" runat="server"> kleur</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 72px;
POSITION: absolute; TOP: 16px" runat="server"
columnKey="naam "></asp:TextBox>
<asp:DropDownLi st id="DropDownLis t1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleu r"></asp:DropDownLis t></DIV>
<BR>
<P align="center"> <INPUT id="igtbl_reOkB tn" style="WIDTH: 50px"
onclick="igtbl_ gRowEditButtonC lick(event);"
type="button" value="OK">&nbs p; <INPUT id="igtbl_reCan celBtn"
style="WIDTH: 50px" onclick="igtbl_ gRowEditButtonC lick(event);"
type="button" value="Cancel"> </P>
</RowEditTemplate >
<RowTemplateSty le BorderColor="Wh ite" BorderStyle="Ri dge"
BackColor="Whit e">
<BorderDetail s WidthLeft="3px" WidthTop="3px" WidthRight="3px "
WidthBottom="3p x"></BorderDetails>
</RowTemplateStyl e>
</igtbl:UltraGrid Band>
</Bands>
</igtbl:ultrawebg rid>


"Daniel Walzenbach" <da************ ***@newsgroup.n ospam> schreef in
bericht news:eo******** ******@TK2MSFTN GP12.phx.gbl...
Oscar,

try the following:

document.getEle mentById("DropD ownList").optio ns[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.n l> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
>I want to add items to a dropdownlist control within a Javascript
>eventhandl er.
> This is what I code :
>
> var dd = document.getEle mentById("DropD ownList1");
>
> dd.Items.Add("1 990");
> dd.Items.Add("1 991");
> dd.Items.Add("1 992");
>
> however, it doesn't work.
>
> What should I code instead ?
>
>



Nov 19 '05 #6
How about using ClientID of the control, and writing out the script from
CodeBehind.
See here for an example:
http://aspnet.4guysfromrolla.com/art...91703-1.2.aspx

Look for the section "Emitting the Client-Side JavaScript"

Regards

"Oscar" <ok*@xs4all.n l> skrev i melding
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Daniel,

You are a hero to me! I've done the view source and I saw that the ID was
rewritten as ID= UltraWebGrid1__ ctl0_DropDownLi st1. I've changed the HTML
source to

document.getEle mentById("Ultra WebGrid1__ctl0_ DropDownList1") .options[0] =
new Option("1990", "1990");

and now it's working!

thank you very much and have a nice day.

regards,
Oscar
"Daniel Walzenbach" <da************ ***@newsgroup.n ospam> schreef in
bericht news:u0******** ******@TK2MSFTN GP14.phx.gbl...
Oscar,

did you check what will be rendered on your page. Do a "View Source" of
the page and check out the naming pattern.

Does this help?

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
309
by: Santhu | last post by:
To the already present dropdownlist control can i add a property so that i can add text plus image to items. Actually my requirement is i want to add text and image to the items in the dropdownlist control. How can i do that, any suggestions are appreciated? Thank you
4
7464
by: theo | last post by:
Program flow...load file,then extract the xml text tags from the file,then the number of Xml tags retrieved from the file determines the number of dropdownlist controls instanciated in the placeholder,the user selects the required tags from the dropdownlists (if 5 Xml tags,then 5 dropdownlists each containing 5 xml tags) and now the btnSave button is selected which extracts the user selection form the dropdownlists.
2
2050
by: Ali | last post by:
I am adding a DropDownList control to my DataGrid footer template. I load my DropDownList using a function that returns an arrayList. I can see all my items in the DropDownList, but when I select an item from the list, I am unable to trap the DropDownList SelectedIndexChanged event. This is a snippet of my DataGrid: <asp:TemplateColumn> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "State") %>
2
2207
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1" Runat="server" DataTextField="PropertyValue" DataValueField="PropertyValueId"> </asp:DropDownList> </ItemTemplate> </asp:DataList>
1
1768
by: Matt | last post by:
Hi. I'm using VS2005 and working with the Dropdownlist control on an ASP page. My dropdownlist has several thousand items, all integers, ranging from 1000 to 80000 (these represent different company acocunts). With that many items, I would like the user to be able to not only choose from the list, but type the number in the list as well to avoid having to scroll through all of them. Now, if the user currently enters a '1', they are...
2
16105
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine in my asp tag as shown here: <asp:DropDownList id="ddlTo" runat="server"
5
2775
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> I have the gridview inside of a master page- content hierarchy.
7
17468
by: =?Utf-8?B?UmVraGE=?= | last post by:
Hi, I am trying to change the font color for the items in a dropdownlist control at run time using ASP.NET 2.0. DropDownList1.Items.Attributes.Add("style", "color:red"); But when I run the application, I don't see any color change. I am using Visual Studio 2005, ASP.NEt 2.0.
1
1266
by: =?Utf-8?B?aUhhdkFRdWVzdGlvbg==?= | last post by:
I have a dropdownlist of width 100px in a webform. When I hit the control, I gets the list of items that I populated in a pageload. My problem is that the items in my dropdown are more in length then a dropdownlist control I want to keep the drop down the same length as it is and when I hit the dropdownlist i should let the user to see the full length in an item. I would also want to display only 5 items when I hit the drop down...
0
9851
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9695
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10902
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10583
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5680
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4481
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3128
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.