NUCLEAR-WAR
New Member
Hi,<BR>I am trying to learn this new ASP+ stuff. I have a dropdownlist box in my old ASP Application.<BR><select><BR> <option><%=Rs("data")%></option><BR> <option>Just Whatever</option><BR></select><BR>So by default when the page first start I would get the Rs("data") to be selected if the Rs is not Empty.<BR><BR>Now in ASP+ I try to use data binding as follow<BR><BR><%@ Import Namespace="System.Data" %><BR><html><BR><head><BR><script language="vb" runat="server"><BR><BR> Sub Page_Load (Sender As Object, E As EventArgs)<BR> If Not Page.IsPostBack Then<BR> <BR> ' create a new array and fill it<BR> Dim data As new ArrayList<BR><BR> data.add ("Test and Development")<BR> data.add ("Light Frabrication")<BR> data.add ("RM&D")<BR> ' now bind the listbox to the array <BR> Section_name.DataSource = data<BR> Section_name.DataBind()<BR> <BR> End if<BR> <BR> End Sub<BR><BR></script><BR><BR><form runat="server"><BR><BR> <asp:dropdownlist id="Section_name" autopostback="true" runat="server" /><BR></head><BR></form><BR><BR><BR>Okie I got the dropdownlist now but how do I make Rs("data") to be my default value????? Or is this the best way to do it<BR>I'm not sure if I fully understand the result you are going for, but try this:<BR><%@ Import Namespace="System.Data" %><BR><html><BR><head><BR><script language="vb" runat="server"><BR><BR>Sub Page_Load (Sender As Object, E As EventArgs)<BR>If Not Page.IsPostBack Then<BR><BR>' create a new array and fill it<BR>Dim dsc As ADODataSetCommand<BR>Dim ds As New DataSet<BR><BR>dsc = New ADODataSetCommand("SELECT Data From myDataBase", "DSN=myDSN")<BR>dsc.FillDataSet(ds, "Data")<BR><BR>Section_name.DataSource = ds.Tables("Data").DefaultView<BR>Section_name.DataBind()<BR>End If<BR>End Sub<BR></script><BR></head><BR><body><BR><form runat="server"><BR><BR><asp:dropdownlist id="Section_name" autopostback="true" runat="server" /><BR></form><BR></body><BR></html><BR><BR>______________________________________<BR>Doug Seven, MCSD<BR>CodeJunkies.Net / ASPNextGen.com<BR>[email protected]<BR><BR>Visit www.ASPNextGen.com or www.theFutureOfASP.com, both brought to you exclusively by CodeJunkies.Net, for tutorials and information on ASP+ - the next generation of Active Server Pages.<BR><BR>http://www.codejunkies.net<BR><BR>"Between two evils, I always choose the one I haven't tried."<BR>--Mae West<BR><BR>