| | |
Dropdownlist Problems
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2005
Posts: 11
Reputation:
Solved Threads: 0
I've got a page that should change, depending on which item on the dropdownlist is chosen. Unfortunately, the page seems to be ignoring whatever's selected and just clinging on to the first item on the list. I'm sure I'm missing something blindingly obvious, but any help would be greatly appreciated.
The dropdownlist is generated in a Page_Load using the following:
While the list itself, plus the results table, is generated as follows:
The dropdownlist is generated in a Page_Load using the following:
ASP.NET Syntax (Toggle Plain Text)
TheSQL = New SqlCommand("Select CatID, CatName from RSG_Category order by CatName", objConn) TheResults = TheSql.ExecuteReader CatID.DataValueField = "CatID" CatID.DataTextField = "CatName" CatID.DataSource=TheResults CatID.DataBind() TheSQL.dispose() TheResults.dispose() objConn.close()
While the list itself, plus the results table, is generated as follows:
ASP.NET Syntax (Toggle Plain Text)
<form runat="server"> <table border="0" cellpadding="0" cellspacing="5" width="98%" align="center"> <tr> <td> <a href="menu.aspx"><img src="images/backbutton.gif" alt="Back" border="0" align="left">Back</a><BR><BR> </td> </tr> <tr> <td> <img src="images/contractor.gif" alt="Contractors" align="left">Current Contractors for <%=session("LogInName")%><BR><BR> <asp:dropdownlist id="CatID" name="CatID" runat="server" /> <asp:Button Text="GO" OnClick="Submit" runat="server"/> </td> </tr> <tr> <td> <asp:GridView ID="GridViewCompanyMany" runat="server" AutoGenerateColumns="False" DataKeyNames="ContID" DataSourceID="SqlDataSource1" AllowSorting="True" AllowPaging="True" width="100%" borderwidth="1" borderstyle="solid" bordercolor="#CCCCCC"> <HeaderStyle HorizontalAlign="Left" backcolor="#9D9D9D" forecolor="#FFFFFF" /> <Columns> <asp:HyperLinkField DataNavigateURLFields="ContID" DataNavigateUrlFormatString="contractorview.aspx?ContID={0}" DataTextField="ContName" HeaderText="Contractor" SortExpression="ContSName" /> <asp:BoundField DataField="ContEmail" HeaderText="Email" SortExpression="ContEmail" /> <asp:BoundField DataField="ContAvDate" HeaderText="Date Available" SortExpression="ContAvDate" /> <asp:BoundField DataField="ContLocation" HeaderText="Location" SortExpression="Location" /> </Columns> <PagerSettings Mode="NumericFirstLast" FirstPageText="First" LastPageText="Last" /> <rowstyle backcolor="#FFFFFF"/> <alternatingrowstyle backcolor="#CCCCCC"/> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="Server" ConnectionString="<%$ConnectionStrings:TheLocalServer%>" ProviderName="<%$ ConnectionStrings:TheLocalServer.providerName%>" SelectCommand="Select ContID, ContFName + ' ' + ContSName as ContName, ContSName, ContEmail, ContAvDate, ContLocation from RSG_Contractor where (Cat1=@CatID or Cat2=@CatID or Cat3=@CatID or Cat4=@CatID or Cat5=@CatID)"> <SelectParameters> <asp:ControlParameter ControlID="CatID" Name="CatID" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> </td> </tr> </table> </form>
•
•
Join Date: Aug 2008
Posts: 2
Reputation:
Solved Threads: 0
Try placing the page load code inside the if condition as below:
ASP.NET Syntax (Toggle Plain Text)
If Not (IsPostBack) Then TheSQL = New SqlCommand("Select CatID, CatName from RSG_Category order by CatName", objConn) TheResults = TheSql.ExecuteReader CatID.DataValueField = "CatID" CatID.DataTextField = "CatName" CatID.DataSource=TheResults CatID.DataBind() TheSQL.dispose() TheResults.dispose() objConn.close() End If
Last edited by RehanaAmiruddin; Aug 27th, 2008 at 6:45 am.
![]() |
Similar Threads
- Datareader...i need help urgently... (VB.NET)
- Using Code 5 System to create forms...I got 3 problems (ASP.NET)
- populate two dropdownlist (C#)
- update the db using values in a datagrid (VB.NET)
- POpulate DataGrid (VB.NET)
- i need help (VB.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Show top readers
- Next Thread: Datagrid to Datatable
| Thread Tools | Search this Thread |
.net 2.0 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child click commonfunctions compatible confirmationcodegeneration content contenttype courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose feedback flash flv form formatdecimal forms formview gridview homeedition iframe iis javascript jquery listbox login menu microsoft mono mouse mssql multistepregistration news numerical objects order panelmasterpagebuttoncontrols parent radio ratings reportemail rotatepage save schoolproject search security serializesmo.table silverlight smartcard software sql-server sqlserver2005 suse textbox tracking typeof unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webprogramming webservice xml youareanotmemberofthedebuggerusers





