RadDropdownlist in Radgrid cause DataRowView error

2 posts, 0 answers
  1. Henry
    Henry avatar
    4 posts
    Member since:
    Nov 2015

    Posted 26 Nov 2015 Link to this post

    I'm using RadDropdownlist in Radgrid,  "SelectedValue " or "Databinding" cause DataRowView . I don't know why?

    Here is my code:

    datasource part

    <asp:SqlDataSource ID="landmarketclasssqldatasource" runat="server" ConnectionString="<%$ ConnectionStrings:myAsystemstring %>"
         SelectCommand="SELECT  [PK_LandMarketClass],[LandMarketClass]  FROM [Ref_LandMarketClass]">
     </asp:SqlDataSource>

     

    <asp:SqlDataSource ID="mysqldatasource" runat="server" ConnectionString="<%$ ConnectionStrings:myAsystemstring %>"
            SelectCommand="select a.PK_land, a.pk_bookID, a.landblockname, a.capacityrate, a.landblockarea, b.landmarketclass, a.pk_period   from LD_Landblock a left join Ref_LandMarketClass b on a.PK_landmarketclass=b.PK_landmarketclass where pk_bookID=@pk_bookID"
            InsertCommand ="insert into ld_landblock (PK_bookID ,landblockname,capacityrate,landblockarea, pk_landmarketclass, pk_period,pk_userIDlasteditor) values(@pk_bookid, @landblockname,@capacityrate,@landblockarea,@pk_landmarketclass,@pk_period,@pk_userIDlasteditor)"
            UpdateCommand ="update ld_landblock set landblockname=@landblockname, capacityrate=@capacityrate, pk_useridlasteditor=@pk_useridlasteditor,landblockarea=@landblockarea, pk_landmarketclass=@pk_landmarketclass where pk_land=@pk_land"
            DeleteCommand="delete  from ld_landblock where pk_land=@pk_land"
           >        
            <SelectParameters>
                <asp:ControlParameter ControlID="HFPK_BookID" Name="pk_bookID" PropertyName="Value" />
            </SelectParameters>
           <InsertParameters>
               <asp:Parameter Name="LandBlockName" Type="String"></asp:Parameter>
               <asp:Parameter Name="CapacityRate" Type="Decimal" ></asp:Parameter>
               <asp:ControlParameter ControlID="HFPK_BookID" Type="Int32" Name="pk_bookID" PropertyName="Value" />
               <asp:ControlParameter ControlID="HFUserID" Type="Int32" Name="pk_userIDlasteditor" PropertyName="Value" />
               <asp:ControlParameter ControlID="HFPK_Period" Type="Int32" Name="pk_period" PropertyName="Value" />
               <asp:Parameter Name="landblockarea" Type="Decimal" />
               <asp:Parameter Name="pk_landmarketclass" Type="Int32" />
           </InsertParameters>
           <UpdateParameters>
               <asp:Parameter Name="PK_land" Type="Object"   />
               <asp:Parameter Name="LandBlockName" Type="String"></asp:Parameter>
               <asp:Parameter Name="CapacityRate" Type="Decimal" ></asp:Parameter>
               <asp:ControlParameter ControlID="HFUserID" Type="Int32" Name="pk_userIDlasteditor" PropertyName="Value" />
               <asp:Parameter Name="landblockarea" Type="Decimal" />
               <asp:Parameter Name="pk_landmarketclass"  Type="Int32" />
           </UpdateParameters>
            <DeleteParameters>
                <asp:Parameter Name="PK_land"  Type="Object"  ></asp:Parameter>
            </DeleteParameters
       </asp:SqlDataSource>

     

    and raddropdownlist in radgrid

    method 1

    <telerik:GridDropDownColumn HeaderText="class" UniqueName="pk_landmarketclass" DataSourceID="landmarketclasssqldatasource"
                           ListTextField="landmarketclass" ListValueField="pk_landmarketclass"   DataField="pk_landmarketclass"  >
                               
                     </telerik:GridDropDownColumn>

    method 2

    <telerik:RadDropDownList  ID="RDDLlandmarketclass" runat="server"  DataSourceID="landmarketclasssqldatasource" DataTextField="landmarketclass"
                                      DataValueField="pk_landmarketclass"    SelectedValue='<%# Bind("PK_landmarketclass") %>'  >
                                  </telerik:RadDropDownList>

     neither of methods works. all of them cause datarowview error.

    my reference: http://demos.telerik.com/aspnet-ajax/dropdownlist/examples/applicationscenarios/dropdownlistingird/defaultcs.aspx

    http://www.telerik.com/forums/bind-dropdown-selected-value-to-a-data-source

    Thanks in advance

  2. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 01 Dec 2015 Link to this post

    Hello Henry,

    It seems that this error is SQL related and not Telerik specific. For testing purpose, could you temporarily remove the DataField property of the GridDropDownColumn and see whether the error will vanish? Also, you can place a testing RadDropDownList outside the grid, remove the SelectedValue property and let me know if the dropdown is bound correctly.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top