This is a migrated thread and some comments may be shown as answers.

RadDropdownlist in Radgrid cause DataRowView error

1 Answer 87 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Henry
Top achievements
Rank 1
Henry asked on 26 Nov 2015, 03:28 PM

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

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 01 Dec 2015, 07:33 AM
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
Tags
DropDownList
Asked by
Henry
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or