Si può fare in tanti modi: uno è questo.
ESEMPIO: tabella delle regioni con dropdown delle province
Nella pagina metti un
<asp:Literal ID="Literal1" runat="server" EnableViewState="false"></asp:Literal>
dove ti pare e piace
Nel codice:
codice:Option Strict On Imports l = libreria.ModuloWeb Imports o = System.Data.OracleClient Partial Class prove_a Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim connessione As o.OracleConnection = Nothing Try connessione = New o.OracleConnection(gl.StringaConnessioneSIA) connessione.Open() Me.Literal1.Text = getTabella(connessione) Catch ex As Exception l.MessaggioErrore(ex) Finally If connessione IsNot Nothing Then connessione.Close() End Try End Sub Private Function getTabella(ByVal connessione As o.OracleConnection) As String Dim dt As DataTable = msora.GetDataTable(connessione, "select * from regioni order by nome_regione") Dim sb As New StringBuilder() sb.Append("<table>") sb.Append("<tr>") sb.Append("<th>Regione</th>") sb.Append("<th>Province</th>") sb.Append("</tr>") For i As Integer = 0 To dt.Rows.Count - 1 sb.Append("<tr>") sb.Append(String.Format("<td>{0}</td>", l.NullToSpace(dt.Rows(i)("nome_regione")))) sb.Append(String.Format("<td>{0}</td>", getProvince(connessione, CInt(dt.Rows(i)("id_regione"))))) sb.Append("</tr>") Next sb.Append("</table>") Return sb.ToString End Function Private Function getProvince(ByVal connessione As o.OracleConnection, ByVal id_regione As Integer) As String Dim dt As DataTable = msora.GetDataTable(connessione, String.Format("select * from province where id_regione = {0} order by nome_provincia", id_regione)) Dim sb As New StringBuilder() sb.Append("<select style=""width:200px;"">") For i As Integer = 0 To dt.Rows.Count - 1 sb.Append(String.Format("<option value=""{0}"">{1}</option>", l.NullToString(dt.Rows(i)("id_provincia")), l.NullToString(dt.Rows(i)("nome_provincia")))) Next sb.Append("</select>") Return sb.ToString End Function End Class

Rispondi quotando
VVoVe: questa mi mancava !
