Annoying problem with event being raised twice

Annoying problem with event being raised twice

am 18.04.2008 17:51:08 von Bieniu

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:




AutoPostBack="True" DataSourceID="sqldsConversionDates"
DataTextField="ConversionDate"
DataValueField="ConversionDate">

ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="owrsp_GetConversionDatesForPOS"
SelectCommandType="StoredProcedure"
DataSourceMode="DataReader">










Visible="false" Font-Size="14px"
Font-Bold="true" Width="100%">

DataKeyField="ProfileID" DataSourceID="sqldsSupportInfo"
Width="100%" RepeatDirection="Horizontal" ShowFooter="False"
ShowHeader="False"
CssClass="dataTable" CellSpacing="-1"
OnPreRender="dlSupportInfo_PreRender">

runat="server" Text='<%# Eval("ProfileID") %>'
ToolTip='<%# "Profil: " + Eval("Name") +
Environment.NewLine + Eval("Description") %>'>


ToolTip="">



ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="owrsp_GetInfoForSupportPOSNeed"
SelectCommandType="StoredProcedure"
DataSourceMode="DataReader"
OnSelected="sqldsSupportInfo_Selected">


Name="conversionDate" PropertyName="SelectedValue"
Type="DateTime" />





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 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 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