Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm 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 can't figure out how both Heading and Headname are getting the same value. I'm sure it's something simple but I just cannot see it. Any ideas? Thanks!

 

<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>

 

<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>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...