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

Adding new record button

3 Answers 1156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 23 Mar 2012, 03:58 PM
I am trying to add a simple add record button to the Header of a RadGrid, but I just can't seem to do it through Editor.  The Edit/Delete functions work fine. Using the latest version of RadControls(downloaded demo yesterday). 
<%@ Control language="vb" Inherits="DotNetNuke.Modules.CSAEditor.View" AutoEventWireup="false" Explicit="True" Codebehind="View.ascx.vb" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<telerik:RadGrid ID="rgcsaEditor" runat="server" AllowAutomaticDeletes="True"
    AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
    AllowMultiRowEdit="True" AutoGenerateColumns="False"
    AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" CellSpacing="0"
    DataSourceID="CSAlDataSource" GridLines="None" Skin="Telerik">
<ClientSettings>
<Selecting CellSelectionMode="None"></Selecting>
    <Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
 
<MasterTableView datakeynames="csaId" datasourceid="CSAlDataSource">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
 
    <Columns>
        <telerik:GridBoundColumn DataField="csaId" DataType="System.Int32"
            Display="False" FilterControlAltText="Filter csaId column" HeaderText="csaId"
            ReadOnly="True" SortExpression="csaId" UniqueName="csaId">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="csaName"
            FilterControlAltText="Filter csaName column" HeaderText="csaName"
            SortExpression="csaName" UniqueName="csaName">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="csaWebAddr"
            FilterControlAltText="Filter csaWebAddr column" HeaderText="csaWebAddr"
            SortExpression="csaWebAddr" UniqueName="csaWebAddr">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="csaNotes"
            FilterControlAltText="Filter csaNotes column" HeaderText="csaNotes"
            SortExpression="csaNotes" UniqueName="csaNotes">
        </telerik:GridBoundColumn>
        <telerik:GridCheckBoxColumn DataField="csaActive" DataType="System.Boolean"
            FilterControlAltText="Filter csaActive column" HeaderText="csaActive"
            SortExpression="csaActive" UniqueName="csaActive">
        </telerik:GridCheckBoxColumn>
        <telerik:GridCheckBoxColumn DataField="csaBuyingClub" DataType="System.Boolean"
            FilterControlAltText="Filter csaBuyingClub column" HeaderText="csaBuyingClub"
            SortExpression="csaBuyingClub" UniqueName="csaBuyingClub">
        </telerik:GridCheckBoxColumn>
    </Columns>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
 
</MasterTableView>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
<asp:SqlDataSource ID="CSAlDataSource" runat="server"
    ConnectionString="<%$ ConnectionStrings:CsalwfConnectionString %>"
    DeleteCommand="usp_DeleteCSA_INFO" DeleteCommandType="StoredProcedure"
    InsertCommand="usp_InsertCSA_INFO" InsertCommandType="StoredProcedure"
    SelectCommand="usp_SelectCSA_INFOsAll" SelectCommandType="StoredProcedure"
    UpdateCommand="usp_UpdateCSA_INFO" UpdateCommandType="StoredProcedure">
    <DeleteParameters>
        <asp:Parameter Name="csaId" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="csaName" Type="String" />
        <asp:Parameter Name="csaWebAddr" Type="String" />
        <asp:Parameter Name="csaNotes" Type="String" />
        <asp:Parameter Name="csaActive" Type="Boolean" />
        <asp:Parameter Name="csaBuyingClub" Type="Boolean" />
        <asp:Parameter Direction="InputOutput" Name="csaId" Type="Int32" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="csaId" Type="Int32" />
        <asp:Parameter Name="csaName" Type="String" />
        <asp:Parameter Name="csaWebAddr" Type="String" />
        <asp:Parameter Name="csaNotes" Type="String" />
        <asp:Parameter Name="csaActive" Type="Boolean" />
        <asp:Parameter Name="csaBuyingClub" Type="Boolean" />
    </UpdateParameters>
</asp:SqlDataSource>

3 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 23 Mar 2012, 07:34 PM
Added code and buttons outside of grid.  codebehind performed manual Insert from stored procedure.  Maybe this is how it needs to be done.  I was hoping for an easier solution.  

<
telerik:RadTextBox ID="txtName" Runat="server"
    EmptyMessage="Enter CSA Name" EnableSingleInputRendering="True"
    LabelWidth="64px" Skin="Forest">
</telerik:RadTextBox>
<telerik:RadTextBox ID="txtWeb" Runat="server"
    EmptyMessage="Enter CSA Web/Email" EnableSingleInputRendering="True"
    LabelWidth="64px" Skin="Forest">
</telerik:RadTextBox>
<telerik:RadTextBox ID="txtNotes" Runat="server"
    EmptyMessage="Enter CSA Notes" EnableSingleInputRendering="True"
    LabelWidth="64px" Skin="Forest">
</telerik:RadTextBox>
<telerik:RadButton ID="btnActive" runat="server" Text="CSA Active" ToggleType="Radio" ButtonType="ToggleButton"></telerik:RadButton>
<telerik:RadButton ID="btnBuyingClub" runat="server" Text="Buying Club" ToggleType="Radio" ButtonType="ToggleButton"></telerik:RadButton>
 
<telerik:RadButton ID="RadButton1" runat="server" Text="Add" Skin="Forest">
</telerik:RadButton>
0
David
Top achievements
Rank 1
answered on 24 Mar 2012, 04:13 AM
Stumbled upon the solution for simple inserts

in the Grid properties, find MasterTableView
Click the +
scroll down to CommandItemDisplay
Choose Top

This adds the Add record button to the top. 
Clicking the Add Record fires the Generic InsertItem Template.

Nice.  Too bad it too me so long to figure this out.  I am sure there is a simple explanation of this somewhere in the documentation.  I just couldn't find it.
Peace
0
Maria Ilieva
Telerik team
answered on 28 Mar 2012, 01:11 PM
Hello David,

Here is a help article which elaborates on this matter:
http://www.telerik.com/help/aspnet-ajax/grid-commanditem-default-behavior.html

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or