Dropdownlist problem

G

Guest

Hi,

I have a dropdownlist box that has a datasource set to a function call. the
function call returns an arraylist. I moved the dropdown from a datagrid
template column that I had it in and it worked with no problem. Now just
being on the page it doesn't call the function call in datasource anymore. I
have enableviewstate set to true. Any ideas?

Thanks,

JJ
 
J

John Saunders

JJ said:
Hi,

I have a dropdownlist box that has a datasource set to a function call.
the
function call returns an arraylist. I moved the dropdown from a datagrid
template column that I had it in and it worked with no problem. Now just
being on the page it doesn't call the function call in datasource
anymore. I
have enableviewstate set to true. Any ideas?

Take a look at the .aspx page. What does the dropdownlist have for its
DataSource property?

John Saunders
 
G

Guest

Hi John,

When I have the dropdownlist control highlighted in its property sheet
under Datasource I have the function method name. I don't bind the control in
code-behind. This way worked when I had this control in a datagrid but now
the datasource method doesn't get called when page gets created.

JJ
 
J

John Saunders

JJ said:
Hi John,

When I have the dropdownlist control highlighted in its property sheet
under Datasource I have the function method name. I don't bind the control
in
code-behind. This way worked when I had this control in a datagrid but now
the datasource method doesn't get called when page gets created.

JJ, I asked you to look at the .aspx file. For instance:

<asp:DropDownList runat="server" id="ddl" DataSource="<%# myfunction() %>"
/>

John Saunders
 
G

Guest

John,

I did, here is what it looks like :

<asp:DropDownList id=ddlSite runat="server" Font-Names="Verdana"
Font-Size="X-Small" Width="128px" ForeColor="Maroon" AutoPostBack="True"
DataSource="<%# ListSites() %>" DataTextField="SiteName"
DataValueField="SiteID"></asp:DropDownList>

JJ
 
J

John Saunders

JJ said:
John,

I did, here is what it looks like :

<asp:DropDownList id=ddlSite runat="server" Font-Names="Verdana"
Font-Size="X-Small" Width="128px" ForeColor="Maroon" AutoPostBack="True"
DataSource="<%# ListSites() %>" DataTextField="SiteName"
DataValueField="SiteID"></asp:DropDownList>

Very good. Now, where is ListSites declared, and how is it declared?

John Saunders
 
G

Guest

It's declared in code behind page as :

protected SitesCol ListSites()
{
return Sites.GetSites(); <- is a data arraylist class.
}

JJ
 
J

John Saunders

JJ said:
It's declared in code behind page as :

protected SitesCol ListSites()
{
return Sites.GetSites(); <- is a data arraylist class.
}

Sorry, my mistake. If the page is compiling, then the method must clearly be
accessible.

I don't see any reason why this wouldn't work. It should either give a
compile error, or else it should call the method. If I were you, I'd make
certain that it does n ot call the method. For instance, insert a "throw new
Exception();" before the return statement.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top