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

Control won't bind the data before ItemCommand

5 Answers 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 13 Sep 2011, 02:51 PM
Hello,
In template column InstantiateIn method I add some control and assign a handler for its DataBinding event. Next, I fire grid edit and update commands from client side. On server side, when ItemCommand event fires, I try to set e.Canceled to false depending on some conditions. But right after that all editor controls become empty. Their DataBind event never fired. What can I do about that?
Thank you.

5 Answers, 1 is accepted

Sort by
0
Dmitry
Top achievements
Rank 1
answered on 15 Sep 2011, 09:46 AM
Anyone?
0
Iana Tsolova
Telerik team
answered on 16 Sep 2011, 09:21 AM
Hi Dmitry,

By default the edit command implicitly invokes rebind. However when you cancel the command this does not happen. So you should probably call Rebind() for the grid explicitly.

Best wishes,
Iana Tsolova
the Telerik team
Browse the vast support resources we have to jump start 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
0
Dmitry
Top achievements
Rank 1
answered on 16 Sep 2011, 11:19 AM
Thank you for advice, it helped. But after Rebind() all controls restored data they have had before, and I need them to show those incorrect data I have entered.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 16 Sep 2011, 12:50 PM
Hello Dmitry,

you can access those controls in itemdatabound.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   
       if (e.Item is GridEditableItem && e.Item.IsInEditMode)
       {
           GridEditableItem item = (GridEditableItem)e.Item;
           // you can get your control
           TextBox TextBox1 = item.FindControl("TextBox1") as TextBox;
           // access your control
       }
   }

If this is not your case then elaborate your scenario.

let me know if any concern.

Thanks,
Jayesh Goyani
0
Dmitry
Top achievements
Rank 1
answered on 16 Sep 2011, 12:58 PM
Well, I didn't think about it :) Thank you very much.
Tags
Grid
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Dmitry
Top achievements
Rank 1
Iana Tsolova
Telerik team
Jayesh Goyani
Top achievements
Rank 2
Share this question
or