Question

I have added Telerik GridView and linked it to my local sql server database. The problem is I can't see any add/insert row functionality and neither can I find the options to enable it. Here's the RadGrid code:

<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticInserts="True" AllowFilteringByColumn="True"
 AllowPaging="True" AllowSorting="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
CellSpacing="0" DataSourceID="SqlDataSource1" GridLines="None" Skin="Silk" Width="987px">
  <ExportSettings ExportOnlyData="True" OpenInNewWindow="True">
    <Pdf AllowAdd="True" AllowCopy="True" />
  </ExportSettings>
  <MasterTableView autogeneratecolumns="False" datakeynames="Id" datasourceid="SqlDataSource1">
    <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="Id" DataType="System.Int32" FilterControlAltText="Filter Id column"
HeaderText="Id" ReadOnly="True" SortExpression="Id" UniqueName="Id">
        <ColumnValidationSettings>
          <ModelErrorMessage Text="" />
        </ColumnValidationSettings>
      </telerik:GridBoundColumn>
      <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="Name"
SortExpression="Name" UniqueName="Name">
        <ColumnValidationSettings>
          <ModelErrorMessage Text="" />
        </ColumnValidationSettings>
      </telerik:GridBoundColumn>
      <telerik:GridBoundColumn DataField="Form" FilterControlAltText="Filter Form column" HeaderText="Form"
SortExpression="Form" UniqueName="Form">
        <ColumnValidationSettings>
          <ModelErrorMessage Text="" />
        </ColumnValidationSettings>
      </telerik:GridBoundColumn>
      <telerik:GridBoundColumn DataField="Price" FilterControlAltText="Filter Price column" HeaderText="Price"
SortExpression="Price" UniqueName="Price">
        <ColumnValidationSettings>
          <ModelErrorMessage Text="" />
        </ColumnValidationSettings>
      </telerik:GridBoundColumn>
      <telerik:GridBoundColumn DataField="Expiry" DataType="System.DateTime" FilterControlAltText="Filter Expiry 
column" HeaderText="Expiry" SortExpression="Expiry" UniqueName="Expiry">
        <ColumnValidationSettings>
          <ModelErrorMessage Text="" />
        </ColumnValidationSettings>
      </telerik:GridBoundColumn>
      <telerik:GridBoundColumn DataField="Quantity" DataType="System.Int32" FilterControlAltText="Filter Quantity 
column" HeaderText="Quantity" SortExpression="Quantity" UniqueName="Quantity">
        <ColumnValidationSettings>
          <ModelErrorMessage Text="" />
        </ColumnValidationSettings>
      </telerik:GridBoundColumn>
    </Columns>
    <EditFormSettings>
      <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    </EditFormSettings>
    <PagerStyle PageSizeControlType="RadComboBox" Mode="Slider"></PagerStyle>
  </MasterTableView>
  <PagerStyle PageSizeControlType="RadComboBox" Mode="Slider"></PagerStyle>
  <FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
Was it helpful?

Solution

You can either add it directly in the aspx like this:

<telerik:RadGrid runat="server" ID="RadGrid1" AllowPaging="True"
                        AllowSorting="True"
                        AutoGenerateColumns="False"
                        AllowAutomaticInserts="True"
                        AllowAutomaticUpdates="True"
                        AllowAutomaticDeletes="True" ShowStatusBar="True"
                        .........

or alternatively in the wizard as per picture, select master page and flag the options: enter image description here

Moreover, make sure you generate the needed CRUD when you define the parameters of the sqlconnection (advanced menu, generate CRUD instructions). I do not see them in your code. In step 2 of this article you will find detail on how to do it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top