| | |
Dropdownlist Problems
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
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
Views: 890 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 activexcontrol advice ajax application asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child class click compatible confirmationcodegeneration content contenttype countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdown dropdownmenu edit feedback flash flv folder form forms google grid gridview homeedition hosting identity iframe iis index javascript jquery list maps menu mono mssql multistepregistration nameisnotdeclared object objects order problem profile ratings refer rotatepage save search security serializesmo.table session silverlight smartcard software sql suse textbox tracking typeof unauthorized update validation vb vb.net video view virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt wizard xml





