Telerik RadGrid中没有添加功能

时间:2013-12-09 14:19:07

标签: asp.net web telerik radgrid

我添加了Telerik GridView并将其链接到我的本地sql server数据库。问题是我看不到任何添加/插入行功能,也无法找到启用它的选项。这是RadGrid代码:

<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>

1 个答案:

答案 0 :(得分:1)

您可以直接在aspx中添加它:

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

或者根据图片在向导中选择母版页并标记选项: enter image description here

此外,确保在定义sqlconnection(高级菜单,生成CRUD指令)的参数时生成所需的CRUD。我在你的代码中没有看到它们。 在this文章的第2步中,您将找到有关如何执行此操作的详细信息。