Allora, siccome sono un po' lessa ora vi posto il codice così vediamo se riuscite a darmi una mano.
Ora io vorrei che nella DDlist chiamata "dropdescription" si popolasse delle descrizioni che fanno parte di ogni singola voce che viene fuori nella textbox "pippo" selezionando una determinata categoria.
<script runat="server">
sub Page_Load(sender AS object, e AS Eventargs)
if Not IsPostBack Then
dim connTbl as SqlConnection
dim cmdSelect as SqlCommand
dim dtrCategories as SqlDataReader
connTbl = new SqlConnection("connessione")
cmdSelect = new SqlCommand ("Select DISTINCT CatId, Categoria from tabella1", connTbl)
connTbl.open()
dtrCategories = cmdSelect.ExecuteReader()
dropCategories.DataSource = dtrCategories
dropCategories.DataTextField = "Categoria"
dropCategories.DataValueField = "CatID"
dropCategories.DataBind()
dropCategories.Items.Insert(0, New ListItem ("", -1))
dtrCategories.Close()
connTbl.Close()
end if
end sub
sub BindVoce (intCatID as Integer)
dim connTbl as SqlConnection
dim cmdSelect as SqlCommand
dim strSelect as string
dim dtrVoce as SqlDataReader
connTbl = new SqlConnection("connessione")
connTbl.open()
strSelect = "Select DISTINCT Voce From tabella2 where catID=@catID"
cmdSelect = new SqlCommand (strSelect, connTbl)
cmdSelect.Parameters.Add("@catID", intCatID)
dtrVoce = cmdSelect.ExecuteReader()
rptVoce.DataSource = dtrVoce
rptVoce.DataBind()
dtrVoce.Close()
connTbl.Close()
end sub
sub dropCategories_SelectedIndexChanged (sender AS object, e AS Eventargs)
dim intCadID as integer
intCadID = dropCategories.SelectedItem.value
if intCadID <> -1 Then
BindVoce (intCadID)
end if
end sub
</script>
<form runat="server">
<asp:dropdownlist Width="200" ID="dropCategories" AutoPostBack="True" OnSelectedIndexChanged="dropCategories_SelectedInd exChanged" runat="server" />
<asp:repeater EnableViewState="false" ID="rptVoce" runat="server">
<itemtemplate>
<asp:Textbox AutoPostBack="true" Width="150" ReadOnly="true" ID="pippo" runat="server" Text='<%# Container.DataItem("Voce") %>' />
<asp:dropdownlist Width="100" ID="dropdescription" runat="server" />
<asp:Textbox Width="100" id="pippo1" runat="server" Text=""/>
</itemtemplate>
</asp:repeater>
</form>
Grazie ancora![]()

Rispondi quotando