1

I update in a datagridview.
I display a combobox and selected in my datasource datatextfield and datavalue field.
When I create my update command, how is it possible to select my value and not my text?

        UpdateCommand="UPDATE Properties SET AgentID =@agent, PropertyType =@type, City =@city, Rooms =@rooms, AreaSize =@surface, Price =@price, Bathrooms =@bathrooms, Description =@description, Address =@address WHERE [PropertyID]=@PropertyID" >

Here is what I tried for one of my combobox:

 <asp:TemplateField HeaderText="DescriptionType" SortExpression="DescriptionType">
 <EditItemTemplate>
     <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="SqlDataSourceType" DataTextField="DescriptionType" DataValueField="TypeID" AutoPostBack="True"  SelectedValue='<%#Bind("TypeID")%>'>
     </asp:DropDownList>
  <asp:SqlDataSource ID="SqlDataSourceType" runat="server" ConnectionString="<%$ ConnectionStrings:RealEstateConnectionString %>" ProviderName="<%$ ConnectionStrings:RealEstateConnectionString.ProviderName %>" SelectCommand="SELECT DISTINCT * FROM [Types]"></asp:SqlDataSource>
 </EditItemTemplate>
     <ItemTemplate>
        <asp:Label ID="Label6" runat="server" Text='<%# Bind("DescriptionType") %>'></asp:Label>
      </ItemTemplate>
       </asp:TemplateField>

          <UpdateParameters>             
          <asp:Parameter Name="TypeID" Type="Int32" />
        </UpdateParameters>

0 Answers0