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

user control edit form

1 Answer 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chom
Top achievements
Rank 1
Chom asked on 03 Dec 2010, 07:38 PM
I need some help ith one o the demos I am trying to use.
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx

I have created a very similar version except that I am using a pop up window instead and 2 ascx user control forms which just allows the user to enter all info and then edit some info.

The first problem is: with this code behind in the RadGrid1_PreRender event.
if (!this.IsPostBack)
{
this.RadGrid1.MasterTableView.Items[1].Edit = true;
this.RadGrid1.MasterTableView.Rebind();
}

I get this error when my page loads.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Now I am using a hierarchy grid which is pullong data from the same db.

The second issue I am having is the Insert and Update button in the user control form .ascx file. I have this code for the update button which is directly from the demo.
    <asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update" Visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>' Font-Size="0.9em" />
</td>
<td>
    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel"
        Font-Size="0.9em" />

For some reason the DataItem is not liked and I am getting this web page request error when I go to edit a record.
Error: Sys.WebForms.PageRequestManagerServerErrorException: c:\test\Web Projects\Sites\Industries VS2008\ Industries\Board\Controls\Admin\EmailSettingsUpdate.ascx(172): error CS0103: The name 'DataItem' does not exist in the current context

Can anyone shed some light here?

Thanks


1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 09 Dec 2010, 08:56 AM
Hello Chom,

1. With regards to your first question, if you need to put a given item into EditMode, you should be accomplishing this in the OnPreRender event in the way you are trying to. Instead, you can use the EditIndexes collection of RadGrid as described in the following help topic:
http://www.telerik.com/help/aspnet-ajax/grdputallitemsineditmodenoadditionalrebind.html

Furthermore, do make sure that you are using Advanced databinding as opposed to Simple databinding.

2. Concerning the second issue, take a look at the following online example and note how the binding expressions are set for the controls in the edit form:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx
 
In addition, do notice how the DataItem property is exposed in the code-behind for the user control.

Hope it helps.


Greetings,
Tsvetoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Chom
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or