My Telerik:RadGrid tag :
<telerik:RadGrid ID="grdSettlement" runat="server" AllowFilteringByColumn="True"
DataSourceID="SqlDataSource1" AllowAutomaticDeletes="True" AllowAutomaticUpdates="True"
AllowAutomaticInserts="true" OnInsertCommand="grdSettlement_InsertCommand">
My Columns :
<telerik:GridTemplateColumn DataField="NO" FilterControlAltText="Filter NO column"
HeaderText="NO" SortExpression="NO" UniqueName="NO" DataType="System.Int64">
<InsertItemTemplate>
<telerik:RadNumericTextBox runat="server" ID="No">
</telerik:RadNumericTextBox>
</InsertItemTemplate>
<ItemTemplate>
<%# Eval("NO") %>
</ItemTemplate>
</telerik:GridTemplateColumn>
C# code to access that :
protected void grdSettlement_InsertCommand(object source, GridItemEventArgs e)
{
((e.Item as GridEditableItem)["NO"].Controls[0] as TextBox).Text = "007";
}
I can Write that some codes but there are give me a Compilation Error... Help me to Solve this...
It's Working with this :
.aspx
<telerik:RadGrid ID="grdSettlement" runat="server" AllowFilteringByColumn="True"
CellSpacing="0" DataSourceID="SqlDataSource1" GridLines="None" AllowAutomaticDeletes="True"
AllowAutomaticUpdates="True" AutoGenerateColumns="False" AllowAutomaticInserts="true"
OnItemDataBound="grdSettlement_ItemDataBound">
.aspx.cs
protected void grdSettlement_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
RadNumericTextBox txtNo = item.FindControl("txtNo") as RadNumericTextBox;
txtNo.Value = 7;
}
}