I have a drop down list, if the person wants to add another company to the list, I hide the drop down list panel and show the text field panel, the user then adds the company and it re-binds the data and then shows the drop down list again.<BR><BR>My problem now is to get the SelectedIndex equal to the entry they just added (in other words, find the last primary key ID and then set it equal to the SelectedIndex property so it can select the entry they just added without them having to go through the whole list)<BR><BR>Normally I would just do a rs.movelast and say mylist.selectedindex = rs("id")<BR><BR>but with this new programming language and wya of doing things I have no idea how to do that..... ANY ideas would be welcome, I am including my code so you may understand it better. (if you see anything that needs a tweak you could post as well, thanks)<BR><BR><% @Import Namespace="System.Data" %><BR><% @Import Namespace="System.Data.OleDb" %><BR><BR><html><BR> <head><BR> <title><BR> </title><BR> </head><BR><BR><script language="VB" runat="server"><BR><BR> Sub Page_Load(Sender As Object, E As EventArgs)<BR><BR> lblCompany.Text = "Company:"<BR> lblStartDate.Text = "Start Date:"<BR> lblEndDate.Text = "End Date:"<BR> lblName.Text = "Name:"<BR> txtStartDate.Text = ""<BR><BR> panelDropDown.Visible = True<BR> panelAddCompany.Visible = False<BR> <BR> BindData()<BR><BR> End Sub<BR><BR> Sub SubmitBtn_Click(Sender As Object, E As EventArgs)<BR><BR> If (Page.IsValid) Then<BR> <BR> End if<BR><BR> End Sub<BR><BR> Sub ShowAddCompany_Click(Sender As Object, E As EventArgs)<BR> <BR> panelDropDown.Visible = False<BR> panelAddCompany.Visible = True <BR><BR> End Sub<BR><BR> Sub AddCompany_Click(Sender As Object, E As EventArgs)<BR> Dim sConnstr As String<BR> sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("dbmca01.mdb") <BR><BR> 'Open connection before populating the DataReader <BR> Dim objConn as New OleDbConnection(sConnStr) <BR><BR><BR> Dim objDs As DataSet <BR> Dim objCmd As OleDbCommand <BR> Dim strInsertCommand As String = "INSERT INTO Company (Com_Name) VALUES (@CompanyName)" <BR><BR> objCmd = New OleDbCommand(strInsertCommand, objConn) <BR> objCmd.Parameters.Add(New OleDbParameter("@CompanyName", OleDbType.VarChar, 255))<BR><BR> objCmd.Parameters("@CompanyName").Value = addcompany.text<BR> objCmd.Connection.Open() <BR><BR> Try <BR> objCmd.ExecuteNonQuery() <BR><BR> Catch Exp As OleDbException <BR> Response.Write("Error Occured: " & Exp.Source) <BR> End Try <BR> objCmd.Connection.Close()<BR> <BR> BindData()<BR><BR><BR> panelDropDown.Visible = true<BR> panelAddCompany.Visible = false<BR> <BR> End Sub<BR><BR> Sub BindData()<BR><BR> 'Create a connection <BR> Dim sConnstr As String<BR> sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("dbmca01.mdb") <BR><BR> 'Open connection before populating the DataReader <BR> Dim objConn as New OleDbConnection(sConnStr) <BR> objConn.Open() <BR><BR> 'Create a command object for the query <BR> Dim strSQL As String<BR> strSQL = "SELECT * FROM Company ORDER BY Com_Name"<BR><BR> 'Create/Populate the DataReader <BR> Dim objCmd as New OleDbCommand(strSQL, objConn) <BR> Dim objDR as OleDbDataReader<BR> objDR = objCmd.ExecuteReader()<BR> lstCompanies.SelectedIndex = 1<BR> lstCompanies.DataSource = objDR <BR> lstCompanies.DataBind()<BR><BR> objConn.Close()<BR><BR> End Sub<BR><BR> Sub ServerValidate (sender As Object, value As ServerValidateEventArgs)<BR><BR> Try<BR> If IsDate(cdate(txtStartDate.Text)) And IsDate(cdate(txtEndDate.Text)) Then<BR> If cdate(txtStartDate.Text) <= cdate(txtEndDate.Text) Then<BR> value.IsValid = True<BR> Exit Sub<BR> End If<BR> End If<BR> Catch E As Exception<BR> ' Do Nothing<BR> End Try<BR> value.IsValid = False<BR><BR> End Sub<BR><BR></script><BR><BR> <body><BR> <form name="frmMain" id="frmMain" method="post" action="addedit.aspx" runat="server"><BR> <table border=0><BR> <tr><BR> <td> <asp:label id="lblCompany" runat="server"/> </td><BR> <aspanel id="panelDropDown" runat="server"><BR> <td> <asp:dropdownlist id="lstCompanies" runat="server" Rows="1" DataTextField="Com_Name" DataValueField="ID" /> <asp:button text="Add Company" OnClick="ShowAddCompany_Click" runat="server"/></td><BR> </aspanel><BR> <aspanel id="panelAddCompany" runat="server"><BR> <td> <asp:textbox id="addcompany" runat="server"/> <asp:button text="Add Company" OnClick="AddCompany_Click" runat="server"/></td><BR> </aspanel><BR> </tr><BR> <tr><BR> <td> <asp:label id="lblStartDate" runat="server"/> </td><BR> <td> <asp:textbox id="txtStartDate" runat="server"/><BR> <a href="javascript:window.open('datelookup.aspx?formname=f rmMain.txtStartDate','calendar_window','width=200, height=188');calendar_window.focus()"><BR> <img src="lookup.gif" border="0"></a><BR> </td><BR> <td><BR> <asp:CustomValidator id="CustomValidator1" ControlToValidate="txtStartDate" OnServerValidate="ServerValidate" Display="Dynamic" Font-Name="verdana" Font-Size="10pt" errormessage="Invalid date selection!" runat="server"/><BR> </td><BR> </tr><BR> <tr><BR> <td> <asp:label id="lblEndDate" runat="server"/> </td><BR> <td><asp:textbox id="txtEndDate" runat="server"/><BR> <a href="javascript:window.open('datelookup.aspx?formname=f rmMain.txtEndDate','calendar_window','width=200,he ight=188');calendar_window.focus()"><BR> <img src="lookup.gif" border="0"></a><BR> </td><BR> <td><BR> <asp:CustomValidator id="CustomValidator2" ControlToValidate="txtEndDate" OnServerValidate="ServerValidate" Display="Dynamic" Font-Name="verdana" Font-Size="10pt" errormessage="Invalid date selection!" runat="server"/><BR> </td><BR> </tr><BR> <tr><BR> <td> <asp:label id="lblName" runat="server"/> </td><BR> <td> <asp:textbox id="txtName" runat="server"/> </td><BR> <td> <asp:RequiredFieldValidator ControlToValidate="txtName" Display="Dynamic" Font-Name="verdana" Font-Size="10pt" errormessage="You must enter your name!" runat=server/> </td><BR> </tr><BR> <tr><BR> <td> <asp:button text="Submit" OnClick="SubmitBtn_Click" runat="server"/> </td><BR> </tr><BR> </table><BR> </form><BR> </body><BR></html><BR>Here is a way to do it. It doesn't use the last ID so its kind of a hack:<BR><BR>within AddCompany_Click:<BR>...insert your data...<BR>binddata()<BR>lstCompanies.ClearSelection<BR>lstCompanies.items.findbytext(addcompany.text).sel ected = true<BR><BR>So what it does is just find the new item within the list after it has been populated, and make it the selected item. I haven't tested this, but it should work.