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

user control used to edit mode

1 Answer 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 04 Mar 2016, 08:16 AM

Hi,

 

I have issue with editmode, When I use automatic update works great, but I want use my template to edit, and when I use usercontrol they don;t update my data, they put empty string to it. Below my code, thanks for any feedback.

Index.aspx

<asp:SqlDataSource ID="ListaRejestr" runat="server"
 
            ConnectionString="<%$ ConnectionStrings:ISAConnectionString2 %>"
 
            UpdateCommand="UPDATE tb_upowaznienSystem SET data_wydania = @data_wydania WHERE nr_upowaznienia = @nr_upowaznienia"
 
  
 
            SelectCommand="lista_uzytkownikow"
 
            SelectCommandType="StoredProcedure">
 
            <SelectParameters>
 
                <asp:SessionParameter Name="iduzytkownika" SessionField="id_komorki"
 
                    DefaultValue="" />
 
                <asp:ControlParameter ControlID="drop_rejestrSytem" Name="systemDrop"
 
                    PropertyName="SelectedValue" />
 
                <asp:SessionParameter Name="CzySystemOgolny" SessionField="CzySystemOgolny"
 
                    Type="String" />
 
                <asp:SessionParameter DefaultValue="" Name="administrator_systemu"
 
                    SessionField="administrator_systemu" Type="String" />
 
            </SelectParameters>
 
            <UpdateParameters>
 
                <asp:Parameter Name="data_wydania" />
 
                <asp:Parameter Name="nr_upowaznienia" />
 
            </UpdateParameters>
 
        </asp:SqlDataSource>
 
        <br />
 
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" Culture="pl-PL" DataSourceID="ListaRejestr" GroupPanelPosition="Top" AllowAutomaticUpdates="True" AutoGenerateColumns="False" >
 
            <GroupingSettings CollapseAllTooltip="Collapse all groups" />
 
            <ExportSettings>
 
                <Pdf PageWidth="">
 
                </Pdf>
 
            </ExportSettings>
 
            <MasterTableView DataSourceID="ListaRejestr" AllowAutomaticUpdates="True" PageSize="20" ClientDataKeyNames="nr_upowaznienia" DataKeyNames="nr_upowaznienia">
 
                <CommandItemSettings ShowAddNewRecordButton="False" />
 
                <Columns>
 
                    <telerik:GridEditCommandColumn CancelText="Anuluj" EditText="Data nadania" HeaderText="Data nadania" InsertText="Wyƛlij" UpdateText="Aktualizuj">
 
                    </telerik:GridEditCommandColumn>
 
                    <telerik:GridBoundColumn DataField="id_upowaznieniaSystem" FilterControlAltText="Filter column column" HeaderText="id_upowaznieniaSystem" UniqueName="column">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="nr_upowaznienia" FilterControlAltText="Filter column1 column" HeaderText="nr_upowaznienia" UniqueName="nr_upowaznienia">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="data_wydania" FilterControlAltText="Filter column2 column" HeaderText="data_wydania" UniqueName="data_wydania">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="data_cofniecia" FilterControlAltText="Filter column3 column" HeaderText="data_cofniecia" UniqueName="column3">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="system" FilterControlAltText="Filter column4 column" HeaderText="system" UniqueName="column4">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="zakres_upowaznienia" FilterControlAltText="Filter column5 column" HeaderText="zakres_upowaznienia" UniqueName="column5">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="nazwisko" FilterControlAltText="Filter column6 column" HeaderText="nazwisko" UniqueName="nazwisko">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="imie" FilterControlAltText="Filter column7 column" HeaderText="imie" UniqueName="column7">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="identyfikator" FilterControlAltText="Filter column8 column" HeaderText="identyfikator" UniqueName="column8">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="id_uzytkownik" FilterControlAltText="Filter column9 column" HeaderText="UpowaĆŒnienie ogĂłlne" UniqueName="column9">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="nazwa_komorki" FilterControlAltText="Filter column10 column" HeaderText="nazwa_komorki" UniqueName="column10">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="nazwa_wydzialu" FilterControlAltText="Filter column11 column" HeaderText="nazwa_wydzialu" UniqueName="column11">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="stanowisko" FilterControlAltText="Filter column12 column" HeaderText="stanowisko" UniqueName="column12">
 
                    </telerik:GridBoundColumn>
 
                    <telerik:GridBoundColumn DataField="nr_poprz" FilterControlAltText="Filter column13 column" HeaderText="nr_poprz" UniqueName="column13">
 
                    </telerik:GridBoundColumn>
 
                </Columns>
 
                <EditFormSettings UserControlName="data_wydania_form.ascx" EditFormType="WebUserControl">
 
                    <EditColumn FilterControlAltText="Filter EditCommandColumn1 column" UniqueName="EditCommandColumn1">
 
                    </EditColumn>
 
                </EditFormSettings>
 
            </MasterTableView>
 
        </telerik:RadGrid>

data_wydania_form.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="data_wydania_form.ascx.cs" Inherits="data_wydania_form" %>
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<table>
 
    <tr>
 
        <td>
 
            Data nadania:
 
        </td>
 
    </tr>
 
    <tr>
 
       <td>
 
         <asp:TextBox ID="data_wydania" DbSelectedDate='<%# DataBinder.Eval(Container, "DataItem.data_wydania") %>' runat="server" TabIndex="1"></asp:TextBox>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td>
 
             <asp:Button ID="btnUpdate" Text="Aktualizuj" runat="server" CommandName="Update" CausesValidation="false"></asp:Button> 
 
             <asp:Button ID="btnCancel" Text="Anuluj" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
 
  
 
        </td>
 
  
 
    </tr>
 
</table>

 

 

regards

 

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 09 Mar 2016, 08:28 AM
Hi,

You can refer to the code in the article below that shows how to retrieve a value from a control in a user control custom edit form in Telerik RadGrid:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/update-records/updating-values-using-usercontrol-and-formtemplate

The example demonstrates how to refer to controls by obtaining references to them with the FindControl(controlId) method. Give it a try and see if it works for you.

Regards,
Pavlina
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
Grid
Asked by
Tom
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or