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

DataItem in a user control editform is null after postback in the editform

2 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Donald
Top achievements
Rank 1
Donald asked on 25 Jan 2012, 07:22 AM
Hi,

I have a user control edit form hooked to a RadGrid, like this demo:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx

I have a dropdownbox in the edit form, with a SelectIndexChanged event handler. When the event fires, the DataItem is null.

In my EditForm.ascx.cs:
protected void Page_Load(object sender, EventArgs e)
 {
    var x = this._dataItem; //x is not null, as expected
 }
  
protected void Product_SelectedIndexChanged(object sender, System.EventArgs e)
{
   var x = this._dataItem; //x is null
}

How would I get DataItem inside the event handler?
Any help with this unexpected behaviour would be appreciated,
Donald

2 Answers, 1 is accepted

Sort by
0
Donald
Top achievements
Rank 1
answered on 26 Jan 2012, 02:50 AM
Hi, I am still having trouble trying to fix this. Please help.
0
Iana Tsolova
Telerik team
answered on 27 Jan 2012, 03:30 PM
Hi Donald,

The _dataItem object is available only during data binding. As the grid is not rebound when the dropdown list invokes postback, the _dataItem is not available.
Can you elaborate a bit what you are trying to achieve so we try providing an alternative solution for you?


Kind regards,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Donald
Top achievements
Rank 1
Answers by
Donald
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or