List Info

Thread: populating dropdown list




populating dropdown list
country flaguser name
United States
2007-10-22 07:33:15

Hi All
I have a dropdown list. id=ddlyear
I have set autopostback=true
I want to populate it in c#
i use following code on page load
for(int i=1985;i<=2010;i++)
ddlyear.items.add(i);

but this does not work.
Could anyone help me out.
Thnx
Anil Kumar

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: populating dropdown list
country flaguser name
United States
2007-10-22 09:45:37

Can we see the event name and the all the code for the page i.e.

protected void Page_Load(...)
{
... code ...
}

The code for the buttons and other events could help. Perhaps the
Page_Load() event is misspelled or has incorrect parameter or does not
fire. The easiest way to find if events fire is Trace.Write basically
turning on trace=true and placing a check on the value of i will help
may give us more info on what is happening i.e.

protected void Page_Load(...)
{
for(int i=1985;i<=2010;i++)
{
Trace.Write("i=",i.ToString());
ddlyear.items.add(i);
}
}

On 10/22/07, Anil Srivastava < anilsri_05%40yahoo.com">anilsri_05yahoo.com> wrote:
&gt;
> Hi All
> I have a dropdown list. id=ddlyear
> I have set autopostback=true
> I want to populate it in c#
> i use following code on page load
>; for(int i=1985;i&lt;=2010;i&#43;+)
&gt; ddlyear.items.add(i);
>
> but this does not work.
&gt; Could anyone help me out.

__._,_.___
.

__,_._,___
Re: populating dropdown list
country flaguser name
United States
2007-10-22 10:00:28

Also, "does not work" isn't very descriptive. Is there an error, or does
nothing happen at all?

On 10/22/07, Charles Carroll < 911%40learnasp.com">911learnasp.com> wrote:
&gt;
> Can we see the event name and the all the code for the page i.e.
>;
> protected void Page_Load(...)
>; {
> ... code ...
> }
>
> The code for the buttons and other events could help. Perhaps the
> Page_Load() event is misspelled or has incorrect parameter or does not
> fire. The easiest way to find if events fire is Trace.Write basically
> turning on trace=true and placing a check on the value of i will help
>; may give us more info on what is happening i.e.
>;
> protected void Page_Load(...)
>; {
> for(int i=1985;i&lt;=2010;i&#43;+)
&gt; {
> Trace.Write("i=",i.ToString());
> ddlyear.items.add(i);
> }
> }
>
> On 10/22/07, Anil Srivastava < anilsri_05%40yahoo.com">anilsri_05yahoo.com<anilsri_05%40yahoo.com>>
> wrote:
&gt; >
>; > Hi All
> > I have a dropdown list. id=ddlyear
> > I have set autopostback=true
> > I want to populate it in c#
> > i use following code on page load
>; > for(int i=1985;i&lt;=2010;i&#43;+)
&gt; > ddlyear.items.add(i);
> >
>; > but this does not work.
&gt; > Could anyone help me out.
>;

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )