我正在尝试将编辑模式设置为Telerik的Radgrid中的incell。有在线示例,但它们都是HTML格式。你怎么能在asp中做到这一点?
P.S。我有一个网格,其中包含从数据库中自动检索的数据。我想要做的是能够单独编辑每个单元格并将它们保存到数据库中。
我无法弄清楚如何编辑任何东西。这是C#和aspx代码。
ASPX:
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<telerik:RadGrid ID="GrdConfig" runat="server" CellSpacing="0" GridLines="None"
EnableLinqExpressions="False" oncolumncreated="GrdConfig_ColumnCreated"
CssClass="MyRadGridCssClass" AllowPaging="True">
<ClientSettings>
<Resizing AllowColumnResize="True" />
<Scrolling AllowScroll="True" />
</ClientSettings>
<MasterTableView>
<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>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
</div>
</form>
C#:
public partial class Configurations : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
** Code to extract data from database goes here**
GrdConfig.DataSource = data;
GrdConfig.DataBind();
GridGroupByExpression expression = GridGroupByExpression.Parse("ConfigFile[Config File:] Group by ConfigFile");
GrdConfig.MasterTableView.GroupByExpressions.Add(expression);
GridColumn cConfig = GrdConfig.MasterTableView.GetColumnSafe("ConfigFile");
cConfig.Visible = false;
GrdConfig.Rebind();
}
protected void GrdConfig_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
if (e.Column is GridGroupSplitterColumn)
{
e.Column.HeaderStyle.Width = Unit.Pixel(1);
e.Column.HeaderStyle.Font.Size = FontUnit.Point(1);
e.Column.ItemStyle.Width = Unit.Pixel(1);
e.Column.ItemStyle.Font.Size = FontUnit.Point(1);
e.Column.Resizable = false;
}
}
protected void GrdConfig_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridGroupHeaderItem)
{
GridGroupHeaderItem groupHeader = (GridGroupHeaderItem)e.Item;
groupHeader.Font.Bold = true;
}
}
}
}