Annoying problem with event being raised twice

I have DataList control on my own contro land it is bind to SqlDataSource
control. My problem is that DataList is getting needed data twice what is
for me very strange. I have some code in OnSelected event of SqlDataSource,
and i was suprised when it was fired twice for every page loading.

His is code of datalist:
<tr>
<td style="width: 5%;">
</td>
<td colspan="3">
<asp:DropDownList ID="ddlConversionDates" runat="server"
AutoPostBack="True" DataSourceID="sqldsConversionDates"
DataTextField="ConversionDate"
DataValueField="ConversionDate">
</asp:DropDownList>
<asp:SqlDataSource ID="sqldsConversionDates" runat="server"
ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="owrsp_GetConversionDatesForPOS"
SelectCommandType="StoredProcedure"
DataSourceMode="DataReader">
<SelectParameters>
<asp:Parameter Name="jo" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td style="width: 5%;">
</td>
<td colspan="3">
<asp:Label ID="lSupportInfo" runat="server" Text=""
Visible="false" Font-Size="14px"
Font-Bold="true" Width="100%"></asp:Label>
<asp:DataList ID="dlSupportInfo" runat="server"
DataKeyField="ProfileID" DataSourceID="sqldsSupportInfo"
Width="100%" RepeatDirection="Horizontal" ShowFooter="False"
ShowHeader="False"
CssClass="dataTable" CellSpacing="-1"
OnPreRender="dlSupportInfo_PreRender">
<ItemTemplate>
<asp:Label Font-Bold="true" ID="ProfileIDLabel"
runat="server" Text='<%# Eval("ProfileID") %>'
ToolTip='<%# "Profil: " + Eval("Name") +
Environment.NewLine + Eval("Description") %>'></asp:Label>

<asp:Label ID="SupportLabel" runat="server" Text='<%#
Eval("Support") + " / " + Eval("Need") %>'
ToolTip=""></asp:Label>

</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="sqldsSupportInfo" runat="server"
ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="owrsp_GetInfoForSupportPOSNeed"
SelectCommandType="StoredProcedure"
DataSourceMode="DataReader"
OnSelected="sqldsSupportInfo_Selected">
<SelectParameters>
<asp:Parameter Name="jo" Type="String" />
<asp:ControlParameter ControlID="ddlConversionDates"
Name="conversionDate" PropertyName="SelectedValue"
Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>

Here i set jo params i page load:

protected void Page_Load(object sender, EventArgs e)
{
//getting JO of updating POS
NavigatorItem selectedItem = (NavigatorItem)Parameters["Item"];
unitName = selectedItem.Text;
GetSelectedItemJO(selectedItem);

//setting parameters of controls
sqldsConversionDates.SelectParameters["jo"].DefaultValue = jo;
sqldsSupportInfo.SelectParameters["jo"].DefaultValue = jo;
}

This is call trace:
Function:
Coordinators_UserControls_Support_POS.sqldsSupportInfo_Selec ted(object,
System.Web.UI.WebControls.SqlDataSourceStatusEventArgs), Thread: 0xF40 <No
Name>, Stack:
App_Web_irip9ki6.dll!Coordinators_UserControls_Support_POS.s qldsSupportInfo_Selected
System.Web.dll!System.Web.UI.WebControls.SqlDataSourceView.O nSelected
System.Web.dll!System.Web.UI.WebControls.SqlDataSourceView.E xecuteSelect
System.Web.dll!System.Web.UI.WebControls.BaseDataList.GetDat a
System.Web.dll!System.Web.UI.WebControls.DataList.CreateCont rolHierarchy
System.Web.dll!System.Web.UI.WebControls.BaseDataList.OnData Binding
System.Web.dll!System.Web.UI.WebControls.BaseDataList.DataBi nd
System.Web.dll!System.Web.UI.WebControls.BaseDataList.Ensure DataBound
System.Web.dll!System.Web.UI.WebControls.BaseDataList.Create ChildControls
System.Web.dll!System.Web.UI.Control.EnsureChildControls
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Page.ProcessRequestMain
System.Web.dll!System.Web.UI.Page.ProcessRequest
System.Web.dll!System.Web.UI.Page.ProcessRequest
System.Web.dll!System.Web.UI.Page.ProcessRequestWithNoAssert
System.Web.dll!System.Web.UI.Page.ProcessRequest
App_Web_w8u2q5zq.dll!ASP.coordinators_coordinatorsportal_asp x.ProcessRequest
System.Web.dll!System.Web.HttpApplication.CallHandlerExecuti onStep.System.Web.HttpApplication.IExecutionStep.Execute
System.Web.dll!System.Web.HttpApplication.ExecuteStep
System.Web.dll!System.Web.HttpApplication.ResumeSteps
System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAs yncHandler.BeginProcessRequest
System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNow
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand
System.Web.dll!System.Web.HttpRuntime.ProcessRequest
WebDev.WebHost.dll!Microsoft.VisualStudio.WebHost.Request.Pr ocess
WebDev.WebHost.dll!Microsoft.VisualStudio.WebHost.Host.Proce ssRequest
[Appdomain Transition]
WebDev.WebHost.dll!Microsoft.VisualStudio.WebHost.Server.OnS ocketAccept
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.WaitCa llback_Context
mscorlib.dll!System.Threading.ExecutionContext.Run
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.Perfor mWaitCallback

Function:
Coordinators_UserControls_Support_POS.sqldsSupportInfo_Selec ted(object,
System.Web.UI.WebControls.SqlDataSourceStatusEventArgs), Thread: 0xF40 <No
Name>, Stack:
App_Web_irip9ki6.dll!Coordinators_UserControls_Support_POS.s qldsSupportInfo_Selected
System.Web.dll!System.Web.UI.WebControls.SqlDataSourceView.O nSelected
System.Web.dll!System.Web.UI.WebControls.SqlDataSourceView.E xecuteSelect
System.Web.dll!System.Web.UI.WebControls.BaseDataList.GetDat a
System.Web.dll!System.Web.UI.WebControls.DataList.CreateCont rolHierarchy
System.Web.dll!System.Web.UI.WebControls.BaseDataList.OnData Binding
System.Web.dll!System.Web.UI.WebControls.BaseDataList.DataBi nd
System.Web.dll!System.Web.UI.WebControls.BaseDataList.Ensure DataBound
System.Web.dll!System.Web.UI.WebControls.BaseDataList.OnPreR ender
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Control.PreRenderRecursiveInter nal
System.Web.dll!System.Web.UI.Page.ProcessRequestMain
System.Web.dll!System.Web.UI.Page.ProcessRequest
System.Web.dll!System.Web.UI.Page.ProcessRequest
System.Web.dll!System.Web.UI.Page.ProcessRequestWithNoAssert
System.Web.dll!System.Web.UI.Page.ProcessRequest
App_Web_w8u2q5zq.dll!ASP.coordinators_coordinatorsportal_asp x.ProcessRequest
System.Web.dll!System.Web.HttpApplication.CallHandlerExecuti onStep.System.Web.HttpApplication.IExecutionStep.Execute
System.Web.dll!System.Web.HttpApplication.ExecuteStep
System.Web.dll!System.Web.HttpApplication.ResumeSteps
System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAs yncHandler.BeginProcessRequest
System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNow
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand
System.Web.dll!System.Web.HttpRuntime.ProcessRequest
WebDev.WebHost.dll!Microsoft.VisualStudio.WebHost.Request.Pr ocess
WebDev.WebHost.dll!Microsoft.VisualStudio.WebHost.Host.Proce ssRequest
[Appdomain Transition]
WebDev.WebHost.dll!Microsoft.VisualStudio.WebHost.Server.OnS ocketAccept
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.WaitCa llback_Context
mscorlib.dll!System.Threading.ExecutionContext.Run
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.Perfor mWaitCallback

Call stacks are different here:
First:
System.Web.dll!System.Web.UI.WebControls.BaseDataList.Ensure DataBound
System.Web.dll!System.Web.UI.WebControls.BaseDataList.Create ChildControls
System.Web.dll!System.Web.UI.Control.EnsureChildControls
Secondo:
System.Web.dll!System.Web.UI.WebControls.BaseDataList.Ensure DataBound
System.Web.dll!System.Web.UI.WebControls.BaseDataList.OnPreR ender
It seems like EnsureDataBound metod doesnt feel that datalist has already
bounded data.

Please help
pb
Bieniu [ Fr, 18 April 2008 17:51 ] [ ID #1945154 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » Annoying problem with event being raised twice

Vorheriges Thema: Difference between ASP.NET Website and ASP.NET Application Project
Nächstes Thema: get/set data web.config