Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is my dropdown list not working?

Status
Not open for further replies.

nevergiveup01

Programmer
Nov 18, 2008
18
US
Hello, I have a details view that updates all fields except my dropdown list selection..is there an extra step I missed when adding a dropdown selection to a template in edit mode of the details view? My table is called tblServiceQuote which has a field called TypeID.. TypeID is a foreign key in tblServiceType..TblServiceType has TypeID and Type.. I set the dropdown list to pull typeID and type and only show type but bind Typid to tblServiceQuote..I have done this in many other clients but cant get it to work in ASP..this seems simple but yet it will not work for me? What am I missing? Below is my code..By the way I only know VB not C#..

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="QuoteID"
DataSourceID="SqlDataSource1" DefaultMode="Edit" Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="QuoteID" HeaderText="QuoteID" InsertVisible="False" ReadOnly="True"
SortExpression="QuoteID" />
<asp:BoundField DataField="QuoteDate" HeaderText="QuoteDate" SortExpression="QuoteDate" />
<asp:BoundField DataField="CustID" HeaderText="CustID" SortExpression="CustID" />
<asp:TemplateField HeaderText="TypeID" SortExpression="TypeID">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" AutoPostBack="True"

DataTextField="Type" DataValueField="TypeID">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TestFeetConnectionString %>"
SelectCommand="SELECT * FROM [tblServiceType]"></asp:SqlDataSource>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("TypeID") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("TypeID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ContactMethID" HeaderText="ContactMethID" SortExpression="ContactMethID" />
<asp:CheckBoxField DataField="Accepted" HeaderText="Accepted" SortExpression="Accepted" />
<asp:BoundField DataField="Comments" HeaderText="Comments" SortExpression="Comments" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestFeetConnectionString %>"
DeleteCommand="DELETE FROM [tblServiceQuote] WHERE [QuoteID] = @QuoteID" InsertCommand="INSERT INTO [tblServiceQuote] ([QuoteDate], [CustID], [TypeID], [ContactMethID], [Accepted], [Comments]) VALUES (@QuoteDate, @CustID, @TypeID, @ContactMethID, @Accepted, @Comments)"
SelectCommand="SELECT QuoteID, QuoteDate, CustID, TypeID, ContactMethID, Accepted, Comments FROM tblServiceQuote WHERE (QuoteDate = (SELECT MAX(QuoteDate) AS Expr1 FROM tblServiceQuote AS tblServiceQuote_1))"
UpdateCommand="UPDATE [tblServiceQuote] SET [QuoteDate] = @QuoteDate, [CustID] = @CustID, [TypeID] = @TypeID, [ContactMethID] = @ContactMethID, [Accepted] = @Accepted, [Comments] = @Comments WHERE [QuoteID] = @QuoteID">
<DeleteParameters>
<asp:parameter Name="QuoteID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="QuoteDate" Type="DateTime" />
<asp:parameter Name="CustID" Type="Int32" />
<asp:parameter Name="TypeID" Type="String" />
<asp:parameter Name="ContactMethID" Type="String" />
<asp:parameter Name="Accepted" Type="Boolean" />
<asp:parameter Name="Comments" Type="String" />
<asp:parameter Name="QuoteID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:parameter Name="QuoteDate" Type="DateTime" />
<asp:parameter Name="CustID" Type="Int32" />
<asp:parameter Name="TypeID" Type="String" />
<asp:parameter Name="ContactMethID" Type="String" />
<asp:parameter Name="Accepted" Type="Boolean" />
<asp:parameter Name="Comments" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
 
in your DDL

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" AutoPostBack="True" DataTextField="Type" DataValueField="TypeID"></asp:DropDownList>

why are u posting back on change? you dont have an event tied to it as far as i can see.

take out AutoPostBack="True" and see if that helps??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top