Hello,
I have this grid structure, in which the field is in the PlaceHolder only have to show the insertion of a new record.
<EditFormSettings EditFormType="Template">
<EditColumn ButtonType="ImageButton" />
<FormTemplate>
<table>
<tr>
<td>Nombre de usuario: </td>
<td>
<asp:TextBox ID="login" runat="server" Text='<%# Bind("Login") %>' />
</td>
</tr>
<asp:PlaceHolder ID="phInsert" runat="server">
<tr>
<td>ContraseƱa: </td>
<td>
<asp:TextBox ID="password" runat="server" Text='<%# Bind("Password") %>' />
</td>
</tr>
</asp:PlaceHolder>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
In code -behind I have the following:
protected void RadGridUserAccount_ItemCommand(object sender, GridCommandEventArgs e)
{
RadGrid grid = sender as RadGrid;
if (e.CommandName == "InitInsert")
{
//var gridEditFormItem = e.Item as GridEditFormItem ?? ((GridDataItem)(e.Item)).EditFormItem;
GridItem cmdItem = grid.MasterTableView.GetItems(GridItemType.CommandItem)[0];
//GridEditFormItem editform = (GridEditFormItem)((Telerik.Web.UI.GridDataItem)(e.Item)).EditFormItem;
PlaceHolder insert = cmdItem.FindControl("phInsert") as PlaceHolder;
//GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;
//PlaceHolder insert = (PlaceHolder)gridEditFormItem.FindControl("phInsert");
insert.Visible = true;
}
}
This code is not working for me, always return NullReferenceException.
Would appreciate help as I have tried in many ways and I always get the same exception.
I have this grid structure, in which the field is in the PlaceHolder only have to show the insertion of a new record.
<EditFormSettings EditFormType="Template">
<EditColumn ButtonType="ImageButton" />
<FormTemplate>
<table>
<tr>
<td>Nombre de usuario: </td>
<td>
<asp:TextBox ID="login" runat="server" Text='<%# Bind("Login") %>' />
</td>
</tr>
<asp:PlaceHolder ID="phInsert" runat="server">
<tr>
<td>ContraseƱa: </td>
<td>
<asp:TextBox ID="password" runat="server" Text='<%# Bind("Password") %>' />
</td>
</tr>
</asp:PlaceHolder>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
In code -behind I have the following:
protected void RadGridUserAccount_ItemCommand(object sender, GridCommandEventArgs e)
{
RadGrid grid = sender as RadGrid;
if (e.CommandName == "InitInsert")
{
//var gridEditFormItem = e.Item as GridEditFormItem ?? ((GridDataItem)(e.Item)).EditFormItem;
GridItem cmdItem = grid.MasterTableView.GetItems(GridItemType.CommandItem)[0];
//GridEditFormItem editform = (GridEditFormItem)((Telerik.Web.UI.GridDataItem)(e.Item)).EditFormItem;
PlaceHolder insert = cmdItem.FindControl("phInsert") as PlaceHolder;
//GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;
//PlaceHolder insert = (PlaceHolder)gridEditFormItem.FindControl("phInsert");
insert.Visible = true;
}
}
This code is not working for me, always return NullReferenceException.
Would appreciate help as I have tried in many ways and I always get the same exception.