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

Modify Insert Grid Item in Postback

2 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 05 Mar 2009, 05:14 PM
For reference, I am using version 2008.03.1125.35.

I have a row still in insert mode and am trying to set a value during a postback.  I have a text box with an affiliated button which launches a different window which allows users to select a value.  When that value is chosen, I want to modify the text box value of the grid in the resultant postback.

It looks like the values of the grid are entirely set by the postback data and databinding is skipped.

Does anyone have any ideas for how to do this?  Or point me at examples. 

I looked for quite awhile but did not find anything -- sorry if I missed something obvious. 

My thanks to anyone who looks at this.

-Kyle



2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 10 Mar 2009, 08:11 AM
Hello Kyle,

You can get a reference, in this case, to the insert item, as shown in the code snippet below:

.cs
  protected void RadGrid2_PreRender(object sender, EventArgs e)  
    {  
        if (RadGrid2.MasterTableView.IsItemInserted)  
        {  
            GridEditableItem insertItem = (GridEditableItem)RadGrid2.MasterTableView.GetInsertItem();  
            (insertItem["UnitPrice"].Controls[0] as TextBox).Text = "CustomValue";  
        }  
    } 

I hope this suggestion helps.

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Kyle
Top achievements
Rank 1
answered on 10 Mar 2009, 03:28 PM
Yes, this helps.  I had been doing it too early so it was being overwritten when the state was being processed.  Doing it in prerender is the natural solution.

Thanks a lot.
Tags
Grid
Asked by
Kyle
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Kyle
Top achievements
Rank 1
Share this question
or