Any thoughts how I can get round this?
Thanks!
10 Answers, 1 is accepted
Edit forms in the grid are loaded on post-back event (when you click edit button) and that is why IsPostBack is always true.
Greetings,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

So can I ever tell if it's a page postback? Also, whenever my usercontrol does a postback it repositions itself back to where it was initially (before I dragge it to a new place). Is there any way the user control can be 'pinned' like the radWindow can?
Thanks very much,
Marcus.
Could you please elaborate more on your scenario? Sending your code (page/user control/code) could help us to get to the source of the issue and find a resolution for you.
Kind regards,
Iana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Hi Iana,
Sure, when I click 'edit' on my grid I show a pop-up user control ('Test2.ascx'). In my form load event of this user control I check to see if it's a postback so that I can initialise the page on the first time through (normal .NET stuff). However, the IsPostBack property is true the first time in (I'd expect this to be false).
Here's the code for my main rid
<
script type="text/javascript">
var popUp;
function PopUpShowing(sender, eventArgs)
{
popUp = eventArgs.get_popUp();
var gridWidth = sender.get_element().offsetWidth;
var gridHeight = sender.get_element().offsetHeight;
var popUpWidth = popUp.style.width.substr(0,popUp.style.width.indexOf("px"));
var popUpHeight = popUp.style.height.substr(0,popUp.style.height.indexOf("px"));
popUp.style.left = ((gridWidth - popUpWidth)/2 + sender.get_element().offsetLeft).toString() +
"px";
popUp.style.top = ((gridHeight - popUpHeight)/2 + sender.get_element().offsetTop).toString() +
"px";
}
</
script>
<!-- content start -->
<
telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</
telerik:RadAjaxManager>
<
telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
Width="75px" Transparency="20">
<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
style="border: 0;" />
</
telerik:RadAjaxLoadingPanel>
<
telerik:RadGrid AutoGenerateEditColumn="True" AutoGenerateColumns="False"
OnItemCreated="RadGrid1_ItemCreated" OnItemCommand="RadGrid1_ItemCommand"
ID="RadGrid1" runat="server" OnExcelMLExportStylesCreated="RadGrid1_ExcelMLExportStylesCreated"
OnExcelMLExportRowCreated="RadGrid1_ExcelMLExportRowCreated" AllowPaging="True" AllowSorting="True" DataSourceID="ObjectDataSource1" GridLines="None"
Skin="Telerik" ShowGroupPanel="True" ShowFooter="True"
OnUpdateCommand="RadGrid1_UpdateCommand"
OnInsertCommand="RadGrid1_InsertCommand" AllowFilteringByColumn="True">
<MasterTableView CommandItemDisplay="Top" DataSourceID="ObjectDataSource1" EditMode="PopUp" DataKeyNames="ID" PageSize="5">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="Id" Visible="false" DataType="System.Int32" HeaderText="Id"
SortExpression="Id" UniqueName="Id">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="InvestmentHouse" HeaderText="Investment House"
SortExpression="InvestmentHouse" UniqueName="InvestmentHouse">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="FundName" HeaderText="Fund Name" SortExpression="FundName"
UniqueName="FundName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Sector" HeaderText="IMA Sector" SortExpression="Sector"
UniqueName="Sector">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Category" HeaderText="Fixed Interest Focus"
SortExpression="Category" UniqueName="Category">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="EquityMarketCap" HeaderText="Equity Market Cap"
SortExpression="EquityMarketCap" UniqueName="EquityMarketCap">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="EquityInvestment" HeaderText="Equity Investment Style"
SortExpression="EquityInvestment" UniqueName="EquityInvestment">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="OBSRRating" HeaderText="OBSR Rating"
SortExpression="OBSRRating" UniqueName="OBSRRating">
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings CaptionFormatString="Edit Fund: {0}" CaptionDataField="FundName" PopUpSettings-ZIndex="4000" EditColumn-Resizable="true" PopUpSettings-Modal="true" UserControlName="~/desktopmodules/FundManager/Test2.ascx" PopUpSettings-ScrollBars="None" EditFormType="WebUserControl">
<EditColumn AutoPostBackOnFilter="true" UniqueName="EditCommandColumn1">
</EditColumn>
<
PopUpSettings ScrollBars="None" Modal="True" ZIndex="4000"></PopUpSettings>
</EditFormSettings>
</MasterTableView>
<SortingSettings SortedBackColor="Azure" />
<ClientSettings EnableRowHoverStyle="true" AllowDragToGroup="True">
<Selecting AllowRowSelect="True" />
<ClientEvents OnPopUpShowing="PopUpShowing" />
</ClientSettings>
<FilterMenu EnableTheming="True" Skin="Hay">
<CollapseAnimation Type="OutElastic" Duration="200"></CollapseAnimation>
</FilterMenu>
</
telerik:RadGrid>
Then, in my user control (Test2.ascx) I do this in my page load ..
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
//do something here...
}
}
And IsPostBack is always true...
Thanks,
Marcus.
Thank you for sending your code.
I followed your scenario in order to replicate the issue. Please try the attached sample and let me know how it works on your end and if I missed something from your logic.
Regarding the IsPostBack: When you click the edit button you perform a postback on which postback the user control is loaded. That is why the Page.IsPostBack property is always true in the user control.
Sincerely yours,
Iana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Was there ever a work-around to determining when to Initialize the control, if IsPostBack is always true? We are running into a situation where we need to DataBind a dropdownlist in our formtemplate usercontrol, but if we DataBind on every postback, then we lose the selected value.
How can we determine if this is the initial loading of the FormTemplate control, so that we only initialize the form at the appropriate time?
Thanks,
-Bridget
The best place for data-binding the DropDownList in the FormTemplate is the ItemDataBound event of the grid. You can refer to the below articles for more information:
http://www.telerik.com/help/aspnet-ajax/grid-custom-edit-forms.html
http://www.telerik.com/help/aspnet-ajax/grid-operations-with-dropdownlist-in-edititemtemplate.html
Regards,
Iana
the Telerik team

In my case i have to load and update two date field in the user control, since ispostback is always true, how do i achive this behaviour.

hi all,
I have one user control with rad grid and rad window . The rad Grid is generated dynamically on page load of user control in is postback. This is user control work in all my conditions with defined functionally …… My problem is – whenever i add this user control to to rad grid edit user control –then my user control (rad grid) columns are not created because of postback gets true of radgrid edit …..
Please provide and way of solution to work out …….
Thank You
I have already provided an answer in the following thread:
http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-edit-form-interim-postbacks-before-final-update.aspx
Please note that avoiding multiple threads with similar issues will enable us to respond more quickly and efficiently to your posts.
Regards,
Eyup
the Telerik team