Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

DropDownList Postback - << VB.NET VERSION >>


Use IsPostBack page property to avoid the reload a DropDownList on PostBack


<%@ Page language="c#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
  if (!IsPostBack)
  {
    OleDbConnection objCon;
    objCon = new OleDbConnection("Provider=sqloledb;Data Source=NOME_DATABASE_SERVER;
        Initial catalog=NOME_DATABASE;User Id=USER_NAME;Password=PASSWORD;");
    DataSet ds = new DataSet();
    OleDbDataAdapter objAdapter = new OleDbDataAdapter("Select ID, TESTO from TABELLA order by TESTO desc", objCon);
    objAdapter.Fill(ds);
    catList.DataSource=ds.tables[0].DefaultView;
    catList.DataValueField="ID";
    catList.DataTextField="TESTO";
    catList.DataBind();
  }
}
</script>
<html>
<body>
<form runat="server" ID="Form1">
<asp:DropDownList id="myDropDownList" runat="server"/>
</form>
</body>
</html>



Download Code...


Print Page


 








Page top

risorse per webmaster