By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 2,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

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

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

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

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

www.walzenbach.net

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

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?

Nov 19 '05 #2

P: n/a
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:ultrawebgrid id="UltraWebGrid1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayout RowHeightDefault="20px" Version="4.00"
BorderCollapseDefault="Separate" Name="UltraWebGrid1">
<AddNewBox>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</HeaderStyleDefault>
<FrameStyle Width="325px" BorderWidth="1px" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="Solid"
Height="200px"></FrameStyle>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid"
BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</FooterStyleDefault>
<ClientSideEvents
BeforeRowTemplateOpenHandler="UltraWebGrid1_Before RowTemplateOpenHandler"
AfterRowTemplateOpenHandler="UltraWebGrid1_AfterRo wTemplateOpenHandler"></ClientSideEvents>
<EditCellStyleDefault BorderWidth="0px"
BorderStyle="None"></EditCellStyleDefault>
<RowStyleDefault BorderWidth="1px" BorderColor="Gray"
BorderStyle="Solid">
<Padding Left="3px"></Padding>
<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
</RowStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand AllowUpdate="RowTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGridColumn HeaderText="naam" Key="naam"
BaseColumnName="">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"></Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn HeaderText="kleur" Key="kleur"
Type="DropDownList" BaseColumnName="">
<ValueList>
<ValueListItems>
<igtbl:ValueListItem DataValue="geel" Key="geel"
DisplayText="geel"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="rood" Key="rood"
DisplayText="rood"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="blauw" Key="blauw"
DisplayText="blauw"></igtbl:ValueListItem>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur"></Header>
</igtbl:UltraGridColumn>
</Columns>
<RowEditTemplate>
<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:DropDownList id="DropDownList1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleur"></asp:DropDownList></DIV>
<BR>
<P align="center"><INPUT id="igtbl_reOkBtn" style="WIDTH: 50px"
onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="OK">&nbsp; <INPUT id="igtbl_reCancelBtn"
style="WIDTH: 50px" onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="Cancel"></P>
</RowEditTemplate>
<RowTemplateStyle BorderColor="White" BorderStyle="Ridge"
BackColor="White">
<BorderDetails WidthLeft="3px" WidthTop="3px" WidthRight="3px"
WidthBottom="3px"></BorderDetails>
</RowTemplateStyle>
</igtbl:UltraGridBand>
</Bands>
</igtbl:ultrawebgrid>


"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in bericht
news:eo**************@TK2MSFTNGP12.phx.gbl...
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

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

www.walzenbach.net

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

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?


Nov 19 '05 #3

P: n/a
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.nl> schrieb im Newsbeitrag
news:ua****************@TK2MSFTNGP15.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:ultrawebgrid id="UltraWebGrid1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayout RowHeightDefault="20px" Version="4.00"
BorderCollapseDefault="Separate" Name="UltraWebGrid1">
<AddNewBox>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</HeaderStyleDefault>
<FrameStyle Width="325px" BorderWidth="1px" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="Solid"
Height="200px"></FrameStyle>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid"
BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</FooterStyleDefault>
<ClientSideEvents
BeforeRowTemplateOpenHandler="UltraWebGrid1_Before RowTemplateOpenHandler"
AfterRowTemplateOpenHandler="UltraWebGrid1_AfterRo wTemplateOpenHandler"></ClientSideEvents>
<EditCellStyleDefault BorderWidth="0px"
BorderStyle="None"></EditCellStyleDefault>
<RowStyleDefault BorderWidth="1px" BorderColor="Gray"
BorderStyle="Solid">
<Padding Left="3px"></Padding>
<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
</RowStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand AllowUpdate="RowTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGridColumn HeaderText="naam" Key="naam"
BaseColumnName="">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"></Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn HeaderText="kleur" Key="kleur"
Type="DropDownList" BaseColumnName="">
<ValueList>
<ValueListItems>
<igtbl:ValueListItem DataValue="geel" Key="geel"
DisplayText="geel"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="rood" Key="rood"
DisplayText="rood"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="blauw" Key="blauw"
DisplayText="blauw"></igtbl:ValueListItem>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur"></Header>
</igtbl:UltraGridColumn>
</Columns>
<RowEditTemplate>
<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:DropDownList id="DropDownList1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleur"></asp:DropDownList></DIV>
<BR>
<P align="center"><INPUT id="igtbl_reOkBtn" style="WIDTH: 50px"
onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="OK">&nbsp; <INPUT id="igtbl_reCancelBtn"
style="WIDTH: 50px" onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="Cancel"></P>
</RowEditTemplate>
<RowTemplateStyle BorderColor="White" BorderStyle="Ridge"
BackColor="White">
<BorderDetails WidthLeft="3px" WidthTop="3px" WidthRight="3px"
WidthBottom="3px"></BorderDetails>
</RowTemplateStyle>
</igtbl:UltraGridBand>
</Bands>
</igtbl:ultrawebgrid>


"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in
bericht news:eo**************@TK2MSFTNGP12.phx.gbl...
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

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

www.walzenbach.net

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

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?



Nov 19 '05 #4

P: n/a
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_DropDownList1. I've changed the HTML
source to

document.getElementById("UltraWebGrid1__ctl0_DropD ownList1").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.nospam> schreef in bericht
news:u0**************@TK2MSFTNGP14.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.nl> schrieb im Newsbeitrag
news:ua****************@TK2MSFTNGP15.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:ultrawebgrid id="UltraWebGrid1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayout RowHeightDefault="20px" Version="4.00"
BorderCollapseDefault="Separate" Name="UltraWebGrid1">
<AddNewBox>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</HeaderStyleDefault>
<FrameStyle Width="325px" BorderWidth="1px" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="Solid"
Height="200px"></FrameStyle>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid"
BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</FooterStyleDefault>
<ClientSideEvents
BeforeRowTemplateOpenHandler="UltraWebGrid1_Before RowTemplateOpenHandler"
AfterRowTemplateOpenHandler="UltraWebGrid1_AfterRo wTemplateOpenHandler"></ClientSideEvents>
<EditCellStyleDefault BorderWidth="0px"
BorderStyle="None"></EditCellStyleDefault>
<RowStyleDefault BorderWidth="1px" BorderColor="Gray"
BorderStyle="Solid">
<Padding Left="3px"></Padding>
<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
</RowStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand AllowUpdate="RowTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGridColumn HeaderText="naam" Key="naam"
BaseColumnName="">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"></Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn HeaderText="kleur" Key="kleur"
Type="DropDownList" BaseColumnName="">
<ValueList>
<ValueListItems>
<igtbl:ValueListItem DataValue="geel" Key="geel"
DisplayText="geel"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="rood" Key="rood"
DisplayText="rood"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="blauw" Key="blauw"
DisplayText="blauw"></igtbl:ValueListItem>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur"></Header>
</igtbl:UltraGridColumn>
</Columns>
<RowEditTemplate>
<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:DropDownList id="DropDownList1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleur"></asp:DropDownList></DIV>
<BR>
<P align="center"><INPUT id="igtbl_reOkBtn" style="WIDTH: 50px"
onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="OK">&nbsp; <INPUT id="igtbl_reCancelBtn"
style="WIDTH: 50px" onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="Cancel"></P>
</RowEditTemplate>
<RowTemplateStyle BorderColor="White" BorderStyle="Ridge"
BackColor="White">
<BorderDetails WidthLeft="3px" WidthTop="3px" WidthRight="3px"
WidthBottom="3px"></BorderDetails>
</RowTemplateStyle>
</igtbl:UltraGridBand>
</Bands>
</igtbl:ultrawebgrid>


"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in
bericht news:eo**************@TK2MSFTNGP12.phx.gbl...
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

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

www.walzenbach.net

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

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?



Nov 19 '05 #5

P: n/a
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.nl> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP09.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_DropDownList1. I've changed the HTML
source to

document.getElementById("UltraWebGrid1__ctl0_DropD ownList1").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.nospam> schreef in
bericht news:u0**************@TK2MSFTNGP14.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.nl> schrieb im Newsbeitrag
news:ua****************@TK2MSFTNGP15.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:ultrawebgrid id="UltraWebGrid1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayout RowHeightDefault="20px" Version="4.00"
BorderCollapseDefault="Separate" Name="UltraWebGrid1">
<AddNewBox>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</HeaderStyleDefault>
<FrameStyle Width="325px" BorderWidth="1px" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="Solid"
Height="200px"></FrameStyle>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid"
BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</FooterStyleDefault>
<ClientSideEvents
BeforeRowTemplateOpenHandler="UltraWebGrid1_Before RowTemplateOpenHandler"
AfterRowTemplateOpenHandler="UltraWebGrid1_AfterRo wTemplateOpenHandler"></ClientSideEvents>
<EditCellStyleDefault BorderWidth="0px"
BorderStyle="None"></EditCellStyleDefault>
<RowStyleDefault BorderWidth="1px" BorderColor="Gray"
BorderStyle="Solid">
<Padding Left="3px"></Padding>
<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
</RowStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand AllowUpdate="RowTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGridColumn HeaderText="naam" Key="naam"
BaseColumnName="">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"></Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn HeaderText="kleur" Key="kleur"
Type="DropDownList" BaseColumnName="">
<ValueList>
<ValueListItems>
<igtbl:ValueListItem DataValue="geel" Key="geel"
DisplayText="geel"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="rood" Key="rood"
DisplayText="rood"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="blauw" Key="blauw"
DisplayText="blauw"></igtbl:ValueListItem>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur"></Header>
</igtbl:UltraGridColumn>
</Columns>
<RowEditTemplate>
<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:DropDownList id="DropDownList1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleur"></asp:DropDownList></DIV>
<BR>
<P align="center"><INPUT id="igtbl_reOkBtn" style="WIDTH: 50px"
onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="OK">&nbsp; <INPUT id="igtbl_reCancelBtn"
style="WIDTH: 50px" onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="Cancel"></P>
</RowEditTemplate>
<RowTemplateStyle BorderColor="White" BorderStyle="Ridge"
BackColor="White">
<BorderDetails WidthLeft="3px" WidthTop="3px" WidthRight="3px"
WidthBottom="3px"></BorderDetails>
</RowTemplateStyle>
</igtbl:UltraGridBand>
</Bands>
</igtbl:ultrawebgrid>


"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in
bericht news:eo**************@TK2MSFTNGP12.phx.gbl...
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

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

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
>I want to add items to a dropdownlist control within a Javascript
>eventhandler.
> This is what I code :
>
> var dd = document.getElementById("DropDownList1");
>
> dd.Items.Add("1990");
> dd.Items.Add("1991");
> dd.Items.Add("1992");
>
> however, it doesn't work.
>
> What should I code instead ?
>
>



Nov 19 '05 #6

P: n/a
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.nl> skrev i melding
news:%2****************@TK2MSFTNGP09.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_DropDownList1. I've changed the HTML
source to

document.getElementById("UltraWebGrid1__ctl0_DropD ownList1").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.nospam> schreef in
bericht news:u0**************@TK2MSFTNGP14.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 discussion thread is closed

Replies have been disabled for this discussion.