This is a migrated thread and some comments may be shown as answers.

[Solved] Problem with web user control insert

2 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
Daniel asked on 04 Dec 2009, 07:11 AM
Hi. I have a nested grid. When I press my 'book' link button (same as insert record) it opens up a web user control. I've trapped any exceptions that might come up and noticed that the exception that is raised is an 'Object reference not set to an instance of an object', when click on my 'book' button. The form comes up okay but cannot insert or even cancel the record. Here is parts of my code:

ASPX
<telerik:GridTemplateColumn UniqueName="ExpandCollapse" HeaderStyle-Width="3%"
    <ItemTemplate> 
        <asp:LinkButton ID="lbBook" Text="Book" CommandName="book" runat="server"></asp:LinkButton> 
    </ItemTemplate> 
</telerik:GridTemplateColumn> 

CS
protected void rgEnvironments_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        try 
        { 
            if (e.CommandName == "book"
            { 
                e.Canceled = true
                rgEnvironments.EditIndexes.Clear(); 
                e.Item.OwnerTableView.EditFormSettings.EditFormType = GridEditFormType.WebUserControl; 
                e.Item.OwnerTableView.EditFormSettings.UserControlName = "/teams/im/environment_usage/insert_usage_form.ascx"
                e.Item.OwnerTableView.InsertItem(); 
            } 
 
        } 
        catch (Exception ex) 
        { 
            Intranet.AppendLogFile(ex.Message + ex.StackTrace); 
        } 
    } 

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 04 Dec 2009, 01:09 PM
Hi Daniel,

I tried your similar scenario and  was able to get it working.Could you make sure that you have not set the AllowAutomaticInsert property of the grid to true. Also consider posting your grid markup here.

Thanks,
Princy

0
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
answered on 07 Dec 2009, 12:36 AM
Thanks for that. I should have realised when the automaticinsert form briefly appears before the custom control. Thanks again Princy.
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Princy
Top achievements
Rank 2
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or