populate another listbox

Posted by Pcsandy under ASP.NET on 4/16/2009 | Views : 1802 | Status : [Member] | Replies : 2
Hi, I have a ap.net 1.1 aplication that use a datalist and at the footer there are two dropdownlist. the second listbox should be filled when a value from the first one is selected. I try using OnSelectedIndexChange with the first listbox this is what I'm using

<TH align="left">
<asp:DropDownList ID="addCompany" Runat="server" datavalueField="idName" DataTextField="name"
AutoPostBack = "true" OnSelectedIndexChanged="<%# fillClase() %>"
DataSource="<%# fillCompany() %>" >
</asp:DropDownList>
</TH>

as you can see I try using outpostback in the first dropdownlist and thought that it will go to the "fillClase" rutine when a value from the first dropdownlist is selected. but it doesn't work as expected.




Responses

Posted by: Vuyiswamb on: 4/16/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Pcsandy

I dont Use Wizards to Bind my Controls. from the code i see you are using a Wizard to bind your Control. Can you Post the code of the Two Dropdownlist where you Bind them. if you say its not working please tell us what Error are you getting and if not what is it that is written on the control


Thank you for Posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Pcsandy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pcsandy on: 4/16/2009 [Member] Starter

Up
0
Down
Sure,
---
<FOOTERTEMPLATE>
<TR>
<TD>
<ASP:BUTTON commandname="addPage" id="butAdd" runat="server" text="ADD"></ASP:BUTTON></TD>
<TH align="left">
<asp:DropDownList ID="addCompany" Runat="server" datavalueField="idName" DataTextField="name"
AutoPostBack = "true" OnSelectedIndexChanged="<%# fillClase() %>"
DataSource="<%# fillCompany() %>" >
</asp:DropDownList>
</TH>
<asp:DropDownList ID="addClase" Runat="server"></asp:DropDownList></TH>
<TH align="left">
<ASP:TEXTBOX id="addYear1" runat="server"></ASP:TEXTBOX></TH>
<TH align="left">
<ASP:TEXTBOX id="addYear2" runat="server"></ASP:TEXTBOX></TH>
</TR>
<TR>
</TR>
</table>
</FOOTERTEMPLATE>
---

- FILL 1st listbox routine
Function fillCompany() As DataTable
Dim objConn As New SqlConnection
(ConfigurationSettings.AppSettings("connSQL"))
Dim objDA As New SqlDataAdapter("exec fillCompany", objConn)
objDA.Fill(dllDataSet, "tblComp")
objConn.Close()
Return dllDataSet.Tables("tblComp")
End Function

Function fillClase() As DataSet
response.write("we are in")
End Function

--- THE PROBLEM IS THAT THE fillclase never fire.
ps, thanks for your help...

Pcsandy, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response