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

RadGrid FormEditTemplate auto update doesn't work

5 Answers 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Henry
Top achievements
Rank 1
Henry asked on 29 Jul 2016, 09:24 AM

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"  />
    
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
     <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <div id="divfilter">
    <br />
    <uc1:UCDynamicFilter runat="server" ID="UCDynamicFilter1" />
    <br />
    </div>
    <div id="divdatatable" runat="server" >
        <br />
        <telerik:RadButton ID="RadBtnExp"  runat="server" Text="导出"   OnClick="RadBtnExp_Click"></telerik:RadButton>
        <telerik:RadGrid ID="RadGrid1" runat="server" ClientSettings-Scrolling-AllowScroll="true"   AllowSorting="True"  Height="500px"
            AllowPaging="true" AllowAutomaticUpdates="True" PageSize="30"  DataSourceID="SqlDataSourceSales"   AutoGenerateColumns="false" >
            <ClientSettings>
                <Scrolling SaveScrollPosition="true" UseStaticHeaders="true" />
            </ClientSettings>
            <MasterTableView EditMode="EditForms" DataKeyNames="ID"  >          
                    <Columns>
                        <telerik:GridEditCommandColumn   UniqueName="EditCommandColumn"  ></telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn UniqueName="ID" DataField="ID" HeaderText="ID" DataType="System.Int32"    ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName="年月" DataField ="年月" HeaderText="年月"  ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName ="公司名称" DataField="公司名称"  HeaderText="地区公司名称" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName ="营销中心项目名称和分期" DataField ="营销中心项目名称和分期" HeaderText="营销项目名称和分期" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName="楼栋" DataField="楼栋" HeaderText ="楼栋"  ></telerik:GridBoundColumn>         
                        <telerik:GridBoundColumn UniqueName="物业类型"  DataField="物业类型" HeaderText="物业类型"  ForceExtractValue="Always" DataType="System.Char" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName ="面积" DataField ="面积" HeaderText="面积(签订-退订)" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign ="Right"  ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName="金额" DataField ="金额" HeaderText="金额(签订-退订)"  DataFormatString="{0:N2}" ItemStyle-HorizontalAlign ="Right" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName="征收方式" DataField="征收方式" HeaderText="征收方式"  ForceExtractValue="Always" DataType="System.Char" ></telerik:GridBoundColumn>
                    </Columns>
                <EditFormSettings  EditFormType="Template">
                    <FormTemplate>
                        <table id="Table1"  style="border-collapse: collapse;">
                            <tr>
                                <td>地区公司名称</td>
                                <td><asp:Label ID="LabelCompany" runat="server" Text ='<%# Bind("公司名称")%>'></asp:Label>  </td>
                            </tr>
                            <tr>
                                <td>营销中心项目名称和分期</td>
                                <td><asp:Label ID="LableProjectFq" runat="server" Text ='<%# Bind("营销中心项目名称和分期")%>'></asp:Label>  </td>
                            </tr>
                            <tr>
                                <td>楼栋</td>
                                <td><asp:Label ID="LabelBuilding" runat="server" Text ='<%# Bind("楼栋")%>'></asp:Label>  </td>
                            </tr>
                            <tr>
                                <td>物业类型</td>
                                <td>
                                    
                                    <asp:DropDownList ID="RDDListbulidingtype" runat="server" DataSourceID="SqlDataSource1" DataValueField="物业类型" DataTextField="物业类型"  SelectedValue ='<%# Bind("物业类型") %>'  AppendDataBoundItems="true" >
                                         <asp:ListItem Selected="True" Text="Select" Value="">
                                         </asp:ListItem>
                                    </asp:DropDownList>
                                    
                                </td>
                            </tr>
                            <tr>
                                <td> 面积</td>
                                <td><asp:Label  ID="LabelArea" runat="server" Text ='<%# Bind("面积")%>'></asp:Label>  </td>
                            </tr>
                            <tr>
                                 <td> 金额</td>
                                <td><asp:Label ID="LabelAmount" runat="server" Text ='<%# Bind("金额")%>'></asp:Label>  </td>
                            </tr>
                            <tr>
                                 <td>征收方式</td>
                                <td>
                                    <telerik:RadDropDownList ID="RDDListTax" runat="server"  SelectedValue='<%# Bind("征收方式") %>' >
                                    <Items >
                                        <telerik:DropDownListItem Text="" Value="" />
                                        <telerik:DropDownListItem Text="简易" Value="简易" />
                                        <telerik:DropDownListItem Text="一般" Value="一般" />
                                    </Items>
                                    </telerik:RadDropDownList>
                                </td>
                               </tr>
                            <tr>
                                 <td><asp:Button ID="btnUpdate" runat="server" Text="保存" CommandName="Update" /></td>
                                 <td><asp:Button ID="btnCancel" runat="server" Text="取消" CommandName="Cancel" /></td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
          </telerik:RadGrid>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"  ConnectionString="<%$ ConnectionStrings:myAsystemstring %>" SelectCommand="select * from 物业类型表"  ></asp:SqlDataSource>
    <asp:SqlDataSource  ID="SqlDataSourceSales" runat="server"  ConnectionString="<%$ ConnectionStrings:myAsystemstring %>"
        SelectCommand="select * from 销售导入表 where 公司名称=@mycompanyname and 项目名称=@myprojectname and 年月=@mydate "
        UpdateCommand ="update 销售导入表 set 物业类型=@buildingtype, 征收方式=@taxtype where ID=@ID">
             <SelectParameters  >
                 <asp:ControlParameter Name="mycompanyname" ControlID="UCDynamicFilter1" PropertyName="FilterCompanyName" />
                 <asp:ControlParameter Name="myprojectname" ControlID="UCDynamicFilter1" PropertyName="FilterProjectName" />
                 <asp:ControlParameter Name="mydate" ControlID="UCDynamicFilter1" PropertyName="FliterDate" />
             </SelectParameters>
            <UpdateParameters >
                <asp:Parameter Name="buildingtype"  Type="String"  />
                <asp:Parameter Name="taxtype" Type="String" />
                <asp:Parameter Name="ID"  Type="Int32" />
            </UpdateParameters>
    </asp:SqlDataSource>

</asp:Content>

There is not code behind revalent to this part. The RadScriptManager is in the Master Page.
I'm using Radgrid Control EditformTemplate and auto update (in my case I don't need delete, insert and data validation ), but update button doesn't work. I have check another thread work which says by using "Update" to commandName of button attribution it will be automatic. and demo which shows code behind only for validation.  The update action now seems only return null values to database. 

 

Thanks in advance.

5 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 03 Aug 2016, 07:12 AM
Hello Henry,

The SQL Update parameters like buildingtype and taxtype should have the same name as with the Bind expression parameter like Text property or SelectedValue ='<%# Bind("物业类型") %>' in order for the grid to pass the info properly:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/automatic-datasource-operations


Regards,
Eyup
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Savino
Top achievements
Rank 1
answered on 23 Mar 2018, 11:13 AM

I am having a similar issue. I have created  programmatically  the page with the guide on your documentation The button Update in the edit template does not work, even if put CommandName="Update" the event grid_UpdateCommand is not fired.
Am I missing something? I want to create   because I have many similar RadGrid in the page.

 I have in rendering di "Add new record" button: I can see the button but with no style or icon. Am  missing some setting on the ViewState?
Thank you!

 

 

 

0
Eyup
Telerik team
answered on 28 Mar 2018, 07:49 AM
Hi Savino,

You can use the following live demo as a comparison to help you in troubleshooting this issue:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/form-template-update/defaultcs.aspx

If the problem remains, you can open a formal support ticket to send us a sample RadGrid web site sample. This will enable us to replicate the issue locally and try to determine the reason behind it.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Savino
Top achievements
Rank 1
answered on 28 Mar 2018, 10:39 AM

Eyup you are not helping anybody here... the support to customers is not copy paste random links to your documentation. I have already read your documentation many times, without finding in it a good example of how to create editable radgrid programmatically .

Anyway I solved the problem by putting the NeedDataSource event in which I populate the grid and by putting grid.MasterTableView.EnableViewState = true.... I hope this will help somebody...

Regards,

Savino

0
Eyup
Telerik team
answered on 02 Apr 2018, 07:33 AM
Hi Savino,

Since this was not a common issue, I suggested the live demo to serve you as a comparison base. And then offered that you share further details with us we can be more helpful by providing more-to-point specific suggestions. I'm glad that you've managed to resolve the issue in a quick manner. And thank you for sharing your findings with our community. I hope it will prove helpful to other developers as well.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular 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
Henry
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Savino
Top achievements
Rank 1
Share this question
or