I’m using a telerik RadGrid, with a UserControl edit form. When the InsertCommand event fires, I get the user control, and find edit controls on it, but there Text properties are all string.Empty. I suspect this has something to do with ViewState, but I don’t know where to begin looking.
protected void jobGrid_InsertCommand(object source, GridCommandEventArgs e) { var editControl = e.Item.FindControl(GridEditFormItem.EditFormUserControlID) as JobEditControl; SqlJobProvider.InsertJob(GetFieldValues(editControl)); } private Dictionary<string, object> GetFieldValues(UserControl editControl) { string tb = (editControl.FindControl('aspText') as TextBox).Text;
I believe your controls are empty because you are rebinding the grid before the inserted event. To avoid such behavior I suggest you populate RadGrid using the NeedDataSource event. It is fired whenever the grid needs rebinding.