rangerstud620
Active member
- Joined
- Jun 14, 2005
- Messages
- 27
Im using a DetailsView to update a SQL database. One row in the DetailsView contains a dropdownlist with a value = Heading and text = Headname. When the database is updated though, the Heading and Headname fields are both filled with the Heading value. I have separate parameters set up for each, so I cant figure out how both Heading and Headname are getting the same value. Im sure its something simple but I just cannot see it. Any ideas? Thanks!
Code:
<asp:TemplateField HeaderText="YP Heading" SortExpression="HEADNAME">
<EditItemTemplate>
<asp:DropDownList ID="ddlHeadings" runat="server" DataSourceID="dsHeadings" DataTextField="HEADNAME"
DataValueField="HEADING" Width="650px" SelectedValue=<%# Bind("HEADING","{0}") %> EnableTheming="True">
</asp:DropDownList><asp:SqlDataSource ID="dsHeadings" runat="server" ConnectionString="<%$ ConnectionStrings:TestCompany %>"
SelectCommand="SELECT [HEADING], [HEADNAME] FROM [HEADINGS] ORDER BY [HEADING]">
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text=<%# Bind("HEADNAME") %>></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Code:
<asp:SqlDataSource ID="dsCompany" runat="server" ConnectionString="<%$ ConnectionStrings:TestCompany %>"
SelectCommand="SELECT * FROM [NewReport] WHERE ([SORTCODE] = @SORTCODE) ORDER BY [LINENUMBER]" UpdateCommand="UPDATE NewReport SET HEADING = @Heading, HEADNAME = @Headname, CHANGES = @Changes, COMMENTS = @Comments WHERE SORTCODE = @Sortcode">
<SelectParameters>
<asp:ControlParameter ControlID="lstCompany" Name="SORTCODE" PropertyName="SelectedValue" />
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter ControlID="DetailsView1$ddlHeadings" Name="Headname" PropertyName="text" Type="string" />
<asp:Parameter Name="Heading" Type="string" />
<asp:Parameter Name="Changes" Type="string" />
<asp:Parameter Name="Comments" Type="string" />
<asp:Parameter Name="Sortcode" Type="string" />
</UpdateParameters>
</asp:SqlDataSource>