I have a web form that is structured like this. This is just an example. I use codebehind for all my controls and web forms.
Orders.aspx
-dgrdOrderList (DataGrid)
--EditItemTemplate
---OrderDetail.ascx
----OrderTypeSelect.ascx
-----dropOrderType (DropDownList)
In other words...
Orders.aspx contains a datagrid (dgrdOrderList) that has the
UserControl OrderDetail.ascx in its EditItemTemplate.
OrderDetail.ascx in turn contains another UserControl OrderTypeSelect.ascx. This control has a databound dropDownList.
Normally, I would call the databinding subroutine from the Page_Load sub in OrderTypeSelect.ascx
like so...
Sub Page_Load()
If Not IsPostBack Then
bind_dropOrderType()
End If
End Sub
The problem is that it is alway seeing IsPostBack as true since OrderDetail.ascx is only displayed when the edit button for the DataGrid item has been clicked. My current solution is to call OrderDetail.bind_dropOrderType() from the OnItemCreated sub for the Datagrid when the ItemType is ListItemType.EditItem. This works and the dropDownList gets bound, but it is kind of a hassle and there are some times I don't want to rebind the dropDownList.
Does anyone have any better solutions for how to handle this? Is there a way to check for a postback for just the UserControl OrderDetail.ascx seperate from the page or its parent control?
Thanks,
JC
Orders.aspx
-dgrdOrderList (DataGrid)
--EditItemTemplate
---OrderDetail.ascx
----OrderTypeSelect.ascx
-----dropOrderType (DropDownList)
In other words...
Orders.aspx contains a datagrid (dgrdOrderList) that has the
UserControl OrderDetail.ascx in its EditItemTemplate.
OrderDetail.ascx in turn contains another UserControl OrderTypeSelect.ascx. This control has a databound dropDownList.
Normally, I would call the databinding subroutine from the Page_Load sub in OrderTypeSelect.ascx
like so...
Sub Page_Load()
If Not IsPostBack Then
bind_dropOrderType()
End If
End Sub
The problem is that it is alway seeing IsPostBack as true since OrderDetail.ascx is only displayed when the edit button for the DataGrid item has been clicked. My current solution is to call OrderDetail.bind_dropOrderType() from the OnItemCreated sub for the Datagrid when the ItemType is ListItemType.EditItem. This works and the dropDownList gets bound, but it is kind of a hassle and there are some times I don't want to rebind the dropDownList.
Does anyone have any better solutions for how to handle this? Is there a way to check for a postback for just the UserControl OrderDetail.ascx seperate from the page or its parent control?
Thanks,
JC