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

radgrid update issue w/ dropdownlist

2 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
d-cpt
Top achievements
Rank 2
d-cpt asked on 06 Jun 2017, 07:41 PM

Hi,

My radgrid using auto ops with template. The update failed due to dropdownlist selectedvalue. If a record's field is null then a update with value will yield error for cannot convert DbNull to Int32. If a record's field has value then a update do nothing but no error.

Please help.

Thanks.

extracted codes from aspx:

    <telerik:RadGrid ID="rgInst" runat="server" CellSpacing="0" GridLines="None" RenderMode="Lightweight" AllowPaging="True" PageSize="10" AllowSorting="true"
      AllowAutomaticUpdates="True" AllowAutomaticInserts="True" AllowAutomaticDeletes="true" AutoGenerateColumns="false" DataSourceID="sdsInstitution"
      OnItemCreated="rgInst_ItemCreated" OnItemInserted="rgInst_ItemInserted" OnItemUpdated="rgInst_ItemUpdated" OnItemDeleted="rgInst_ItemDeleted" OnItemCommand="rgInst_ItemCommand">
      <PagerStyle Mode="NextPrevNumericAndAdvanced" />
      <MasterTableView AutoGenerateColumns="false" DataSourceID="sdsInstitution" DataKeyNames="InstID, InstTypeId" CommandItemDisplay="Top" EditMode="EditForms">       
        <Columns>
          <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" />
          <telerik:GridBoundColumn UniqueName="InstName" DataField="InstName" HeaderText="Institution" />
          <telerik:GridBoundColumn UniqueName="CampusType" DataField="InstTypeDesc" HeaderText="Campus Type" />
          <telerik:GridButtonColumn Text="Deactivate" CommandName="Delete" />
        </Columns>
  
  <EditFormSettings EditFormType="Template">
          <FormTemplate>
            <br />
                  <table class="tableW100">
                    <tr>
                      <td class="td30R">Institution name:</td>
                      <td class="td70L">
                        <asp:TextBox ID="tbInstName" runat="server" CssClass="tbW100" Text='<%# Bind("InstName") %>' />
                      </td>
                    </tr>
                    <tr>
                      <td class="td30R">School/Department:</td>
                      <td class="td70L">
                        <asp:TextBox ID="tbInstOffice" runat="server" CssClass="tbW100" TextMode="MultiLine" Text='<%# Bind("InstOffice") %>' />
                      </td>
                    </tr>
                    <tr>
                      <td class="td30R">Campus Type:</td>
                      <td class="td70L">
                        <asp:DropDownList ID="ddlInstType" CssClass="tbW100" runat="server" DataSourceID="sdsInstType" DataTextField="InstTypeDesc" DataValueField="InstTypeID" SelectedValue='<%# Bind("InstTypeID") %>'
                          AppendDataBoundItems="True">
                          <asp:ListItem Selected="True" Text="Select..." Value="" />
                        </asp:DropDownList>
                      </td>
                    </tr>
              <tr>
                <td colspan="2" class="tr4Btn">
                  <asp:Button ID="btnUpdate" CssClass="flatbtnFlexSmall" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' />&nbsp;
                  <asp:Button ID="btnCancel" CssClass="flatbtnFlexSmall" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" />
                </td>
              </tr>
            </table>
          </FormTemplate>
        </EditFormSettings>
      </MasterTableView>
    </telerik:RadGrid>

 

<asp:SqlDataSource ID="sdsInstitution" runat="server" ConnectionString="<%$ ConnectionStrings:MainDB %>"
    SelectCommand="sprInstitutionGet" SelectCommandType="StoredProcedure"
    UpdateCommand="sprInstitutionUpdate" UpdateCommandType="StoredProcedure"
    InsertCommand="sprInstitutionAdd" InsertCommandType="StoredProcedure"
    <InsertParameters>
      <asp:Parameter Name="InstName" Type="String" />
      <asp:Parameter Name="InstOffice" Type="String" />
      <asp:Parameter Name="InstTypeID" Type="Int32" />
      <asp:SessionParameter Name="ModBy" SessionField="AdmNetID" Type="String" />
    </InsertParameters>
    <UpdateParameters>
      <asp:Parameter Name="InstID" Type="Int32" />
      <asp:Parameter Name="InstName" Type="String" />
      <asp:Parameter Name="InstOffice" Type="String" />
      <asp:Parameter Name="InstTypeID" Type="Int32" />
      <asp:SessionParameter Name="ModBy" SessionField="AdmNetID" Type="String" />
    </UpdateParameters>
</asp:SqlDataSource>

 

<asp:SqlDataSource ID="sdsInstType" runat="server" ConnectionString="<%$ ConnectionStrings:MainDB %>" SelectCommand="sprInstitutionTypeGet" SelectCommandType="StoredProcedure" />

 

 

 

 

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
d-cpt
Top achievements
Rank 2
answered on 07 Jun 2017, 07:28 PM

I am still working on this issue. It seems auto update does not get the changed value of dropdownlists. Hopefully Telerik could help.

d-cpt

 

0
Eyup
Telerik team
answered on 09 Jun 2017, 09:10 AM
Hi,

I've already replied to your ticket with ID: 1113443. I suggest that we continue our conversation on the mentioned thread.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
d-cpt
Top achievements
Rank 2
Answers by
d-cpt
Top achievements
Rank 2
Eyup
Telerik team
Share this question
or