This project is read-only.

Radgrid edit example

Jan 5, 2011 at 11:39 AM

Is there any example to create a radgrid wich is editable?

Coordinator
Jan 5, 2011 at 7:00 PM

Hello,

First of all I'd like to advice create a UserControl (ascx) and just embed it on the page using XsltDb.

Here is basic sample of how you can edit data using Telerik RadGrid

you have to create the following table:

 

create table People
(
   ID int identity primary key,
   FirstName nvarchar(100),
   LastName nvarchar(100)
)
 

 

And then use the following configuration (ensure you have Super Module option checked):
Review it live: http://xsltdb.com/Telerik/EditableRadGrid.aspx

 

<mdo:asp xmlns:asp="asp" xmlns:telerik="telerik">
      <asp:SqlDataSource
          id="dsPeople"
          runat="server"
          EnableCaching="False"
          ConnectionString="&lt;%$ ConnectionStrings:SiteSqlServer %&gt;"
          SelectCommand="SELECT ID, FirstName, LastName FROM People"
          InsertCommand="INSERT People(FirstName, LastName) VALUES(@FirstName, @LastName)"
          UpdateCommand="UPDATE People SET FirstName = @FirstName, LastName = @LastName WHERE ID = @ID"
          DeleteCommand="DELETE People WHERE ID = @ID"
       />
      <telerik:RadGrid
          DataSourceID="dsPeople"
          DataKeyNames="ID"

          AllowPaging="True"
          PageSize="10"

          AutoGenerateColumns="False"

          AllowAutomaticDeletes="True"
          AllowAutomaticInserts="True"
          AllowAutomaticUpdates="True"

          Skin="Office2007"
          runat="server">

        <MasterTableView EditMode="InPlace" CommandItemDisplay="Bottom"
DataSourceID="dsPeople" DataKeyNames="ID"> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"/> <telerik:GridBoundColumn DataType="System.String" DataField="FirstName" HeaderText="First Name" UniqueName="FirstName" /> <telerik:GridBoundColumn Visible="False" DataType="System.Int32" DataField="ID" HeaderText="ID" UniqueName="ID" /> <telerik:GridBoundColumn DataField="LastName" DataType="System.String" HeaderText="Last Name" UniqueName="LastName" /> <telerik:GridButtonColumn ConfirmText="Delete this person?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" /> </Columns> </MasterTableView> </telerik:RadGrid> </mdo:asp>

 

 

 

 

Apr 3, 2011 at 5:55 PM

Hello,

I need to add a radeditor, changed to read a new table, but I get error on line content of the bind.
What syntax should I use to solve, have any documentation on this.

 

<mdo:asp xmlns:asp="asp" xmlns:telerik="telerik">

     <asp:SqlDataSource

         id="dsProducts"

         runat="server"

         EnableCaching="False"

         ConnectionString="&lt;%$ ConnectionStrings:SiteSqlServer %&gt;"

         SelectCommand="SELECT cntID, Produto, IDUnidade, IDCategoria, CategoriaFrac, Comentarios, Sort, Fracionado, Visible FROM DHO_Produtos WHERE Visible = 1 AND IDCategoria = 14"

         InsertCommand="INSERT DHO_Produtos(Produto, IDUnidade, IDCategoria, CategoriaFrac, Comentarios, Sort, Fracionado, Visible) VALUES(@Produto, @IDUnidade, @IDCategoria, @CategoriaFrac, @Comentarios, @Sort, @Fracionado, @Visible)"

         UpdateCommand="UPDATE DHO_Produtos SET Produto = @Produto, IDUnidade = @IDUnidade, IDCategoria = @IDCategoria, CategoriaFrac = @CategoriaFrac, Comentarios = @Comentarios, Sort = @Sort, Fracionado = @Fracionado, Visible = @Visible WHERE cntID = @cntID"

         DeleteCommand="DELETE FROM DHO_Produtos WHERE cntID = @cntID"

       />

     <telerik:RadGrid

       DataSourceID="dsProducts"

         DataKeyNames="cntID"

 

         AllowPaging="True"

         PageSize="5"

 

         AutoGenerateColumns="False"

 

         AllowAutomaticDeletes="True"

         AllowAutomaticInserts="True"

         AllowAutomaticUpdates="True"

 

         Skin="Windows7"

         runat="server">

 

       <MasterTableView EditMode="InPlace" CommandItemDisplay="Bottom" DataSourceID="dsProducts" DataKeyNames="cntID">

         <Columns>

        

           <telerik:GridEditCommandColumn

             ButtonType="ImageButton"

             UniqueName="EditCommandColumn"/>

 

           <telerik:GridBoundColumn

             Visible="False"

             DataType="System.Int32"

             DataField="cntID"

             HeaderText="Código"

             UniqueName="cntID" />

 

           <telerik:GridBoundColumn

             DataType="System.String"

             DataField="Produto"

             HeaderText="Produto"

             UniqueName="Produto" />

            

           <telerik:GridBoundColumn

             DataField="IDUnidade"

             DataType="System.Int32"

             HeaderText="Unidade"

             UniqueName="IDUnidade" />

            

           <telerik:GridBoundColumn

             DataField="IDCategoria"

             DataType="System.Int32"

             HeaderText="Categoria"

             UniqueName="IDCategoria" />

            

           <telerik:GridBoundColumn

             DataField="CategoriaFrac"

             DataType="System.String"

            HeaderText="Categoria Frac"

             UniqueName="CategoriaFrac" />

            

           <telerik:GridBoundColumn

             DataField="Sort"

             DataType="System.String"

             HeaderText="Ordem"

             UniqueName="Sort" />

            

           <telerik:GridBoundColumn

             DataField="Fracionado"

             DataType="System.Bit"

             HeaderText="Fracionado"

             UniqueName="Fracionado" />

            

           <telerik:GridBoundColumn

             DataField="Visible"

             DataType="System.Bit"

             HeaderText="Visivel"

             UniqueName="Visible" />

          

           <telerik:GridBoundColumn

             DataField="Comentarios"

             DataType="System.String"

             HeaderText="Descrição"

             UniqueName="Comentarios" />

            

           <telerik:GridTemplateColumn>

               <ItemTemplate>

                   <asp:Label ID="lblField1" CssClass="text" runat="server" Text="Comentarios" />

               </ItemTemplate>

               <EditItemTemplate>

                   <telerik:RadEditor ID="Comentarios" runat="server" Content='<%# Bind("Content") %>'>

                       <Tools>

                           <telerik:EditorToolGroup>

                               <telerik:EditorTool Name="Cut" />

                               <telerik:EditorTool Name="Copy" />

                               <telerik:EditorTool Name="Paste" />

                           </telerik:EditorToolGroup>

                       </Tools>

                   </telerik:RadEditor>

               </EditItemTemplate>

               <InsertItemTemplate>

                   <telerik:RadEditor ID="Comentarios" runat="server" Content='<%# Bind("Content") %>'>

                        <Tools>

                           <telerik:EditorToolGroup>

                               <telerik:EditorTool Name="Cut" />

                               <telerik:EditorTool Name="Copy" />

                               <telerik:EditorTool Name="Paste" />

                           </telerik:EditorToolGroup>

                       </Tools>

                   </telerik:RadEditor>

               </InsertItemTemplate>

           </telerik:GridTemplateColumn>

 

           <telerik:GridButtonColumn

             ConfirmText="Excluir este produto?" ConfirmDialogType="RadWindow"

             ConfirmTitle="Apagar" ButtonType="ImageButton"

             CommandName="Delete" Text="Apagar"

             UniqueName="DeleteColumn" />

 

         </Columns>

       </MasterTableView>

     </telerik:RadGrid>

</mdo:asp>