473,770 Members | 1,954 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ObjectDataSourc e OnSelected event raised twice

This event seems to be being raised twice in my codebehind. I have
only one SelectMethod and do not have a SelectCountMeth od. Its causing
a problem because I'm dynamically loading a user control into a
PlaceHolder control in the method and am having to do a check to see
if it already exists or not otherwise it gets loaded twice. Also it
would be nice to figure out what the heck is going on! Here is the
code ...
protected void odsCatalogues_S elected(object sender,
ObjectDataSourc eStatusEventArg s e)
{
Response.Write( "event called");
Response.Write( "<br />");
if (e.ReturnValue != null)
{
PagedDataSource pds = (PagedDataSourc e)e.ReturnValue ;
totalRowCount = pds.DataSourceC ount;

lblPageInfo.Tex t = totalRowCount + " records found. Page "
+ (pageIndex + 1) + " of " + pageCount;

if (PlaceHolder1.C ontrols.Count == 0)
{
Control control1 = Page.LoadContro l("~/UserControls/
NumericPager.as cx");
UserControls_Nu mericPager numericPager1 =
(UserControls_N umericPager)con trol1;
numericPager1.P ageCount = pageCount;
numericPager1.P ageIndex = pageIndex;
PlaceHolder1.Co ntrols.Add(nume ricPager1);
}
}
}
Anybody got any ideas why this event is being called twice?

Jul 10 '07 #1
4 4515
On Jul 10, 8:25 pm, chris.c.woodw.. .@gmail.com wrote:
This event seems to be being raised twice in my codebehind. I have
only one SelectMethod and do not have a SelectCountMeth od. Its causing
a problem because I'm dynamically loading a user control into a
PlaceHolder control in the method and am having to do a check to see
if it already exists or not otherwise it gets loaded twice. Also it
would be nice to figure out what the heck is going on! Here is the
code ...

protected void odsCatalogues_S elected(object sender,
ObjectDataSourc eStatusEventArg s e)
{
Response.Write( "event called");
Response.Write( "<br />");

if (e.ReturnValue != null)
{
PagedDataSource pds = (PagedDataSourc e)e.ReturnValue ;
totalRowCount = pds.DataSourceC ount;

lblPageInfo.Tex t = totalRowCount + " records found. Page "
+ (pageIndex + 1) + " of " + pageCount;

if (PlaceHolder1.C ontrols.Count == 0)
{
Control control1 = Page.LoadContro l("~/UserControls/
NumericPager.as cx");
UserControls_Nu mericPager numericPager1 =
(UserControls_N umericPager)con trol1;
numericPager1.P ageCount = pageCount;
numericPager1.P ageIndex = pageIndex;
PlaceHolder1.Co ntrols.Add(nume ricPager1);
}
}
}

Anybody got any ideas why this event is being called twice?
can you pleasae provide some aditional code how do you bind the grid

nahid
http://nahidulkibria.blogspot.com/
http://www.kaz.com.bd

Jul 10 '07 #2

Thanks for your reply.

I'm using a DataList bound to an ObjectDataSourc e. Here is the HTML
markup in the relevant .aspx page with some code removed for clarity:

<asp:DataList ID="dlCatalogue s" runat="server"
DataSourceID="o dsCatalogues" EnableViewState ="false">

...

</asp:DataList>

<asp:ObjectData Source ID="odsCatalogu es" runat="server"
SelectMethod="S electCatalogues " TypeName="AGT.B usiness.EventDB "
OnSelected="ods Catalogues_Sele cted"
OnSelecting="od sCatalogues_Sel ecting">
<SelectParamete rs>
<asp:Paramete r ... />
<asp:ControlPar ameter ... /
>
<asp:QueryStrin gParameter ... /
>
<asp:QueryStrin gParameter ... /
>
<asp:QueryStrin gParameter ... /
>
<asp:Paramete r ... />
</SelectParameter s>
</asp:ObjectDataS ource>

Jul 11 '07 #3
On Jul 11, 2:35 pm, chris.c.woodw.. .@gmail.com wrote:
Thanks for your reply.

I'm using a DataList bound to an ObjectDataSourc e. Here is the HTML
markup in the relevant .aspx page with some code removed for clarity:

<asp:DataList ID="dlCatalogue s" runat="server"
DataSourceID="o dsCatalogues" EnableViewState ="false">

...

</asp:DataList>

<asp:ObjectData Source ID="odsCatalogu es" runat="server"
SelectMethod="S electCatalogues " TypeName="AGT.B usiness.EventDB "
OnSelected="ods Catalogues_Sele cted"
OnSelecting="od sCatalogues_Sel ecting">
<SelectParamete rs>
<asp:Paramete r ... />
<asp:ControlPar ameter ... /

<asp:QueryStrin gParameter ... /

<asp:QueryStrin gParameter ... /

<asp:QueryStrin gParameter ... /

<asp:Paramete r ... />
</SelectParameter s>
</asp:ObjectDataS ource>
can you please check this post
http://www.dotnetspider.com/qa/Question13248.aspx
hope help

nahid
http://nahidulkibria.blogspot.com/
http://www.kaz.com.bd
Jul 11 '07 #4
Think I've figured out what was going on.

The ObjectDataSourc e markup contained this line:

<asp:ControlPar ameter DefaultValue="0 " Name="clientId" Type="Int32"
ControlID="DDLi st1" PropertyName="S electedValue" />

where DDList1 is actually a data driven UserControl I have created.

Replacing the line with:

<asp:Paramete r DefaultValue="0 " Name="clientId" Type="Int32" />

and setting the value in the ObjectDataSourc e Selecting event:

protected void odsCatalogues_S electing(object sender,
ObjectDataSourc eSelectingEvent Args e)
{
e.InputParamete rs["clientId"] =
Convert.ToInt32 (DDList1.Select edValue);
}

meant that my DataList databinding was now not occurring twice.

Still not sure why this should be but this work around has fixed it.

:)

Jul 11 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
8705
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action buttons?
5
1990
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as parameter. When the Update-method is invoked by the ObjectDataSource, the object referenced is not the same object returned by the Select-method, but a new object with only the values from the Edit-template. So basically I get a reference to a useless...
3
2429
by: CWWong | last post by:
I am using DetailsView using ObjectDataSource with DataSourceTypeName assigned to the specific class. SelectMethod, UpdateMethod and DeleteMethod is working successfully, except InsertMethod. The error msg returned is: Cannot insert the employee. With tracing trigger on, I had discovered that the parameter is actually empty. The data entered is not pass into the parameter at all !!! What could be the possible reason?
9
11835
by: J055 | last post by:
Hi I'm trying to get an instance of UserLists to persist after it's been used by the GridView. I understand from the documentation that The OnObjectCreated event allows access to the instance. I have a TotalUsers property which is initiated when the GetUsers method is called, however it is empty after the OnObjectCreated event runs. What am I doing wrong? Is there a way to get the Row count from the GetUsers method (It is a DataTable)?...
0
1734
by: Dan Sikorsky | last post by:
I'm using a stored procedure as the select command for an SqlDataSource tied to a GridView. I've verified the sp returns rows in the Management Studio as well as in VS2005 when I Configure the SqlDataSource and click the Test Query button. However, when I run the website in VS2005, the GridView is empty, and when I put a breakpoint in the SqlDataSource_OnSelected event handler, it never breaks. The the SqlDataSource_OnSelecting event...
10
4581
by: J055 | last post by:
Hi I've been trying out SqlCacheDependency using the ObjectDataSource and SQL Server 2005. It all works quite well with the minimum of configuration, e.g. <asp:ObjectDataSource ID="odsAccounts" runat="server" ... EnableCaching="true" SqlCacheDependency="CommandNotification"> .... </asp:ObjectDataSource>
4
1268
by: Samuel Shulman | last post by:
Hi Can anyone explain why the Load Even is raised twice in the web page? What can be done to avoid it? Thanks, Samuel
3
8108
by: KaOne | last post by:
Hi All, excuse me in advance for my not very perfect english. I need some help about a problem with a FormView bounded to an ObjectDataSource. In practise I have an ObjectDataSource that uses some BLL methods that implements the optimistic concurrency by a TimeStamp field into the DB. So, when I execute an insert, update or delete query if I receive 0 like return value from that queries I understand that a concurrency problem is occurs so...
4
4705
by: TarTar | last post by:
Hello, I have already posted this problem, but I have not received any response yet. I will try to describe it again. We have a list control (e.g. DataList) and an ObjectDataSource on an ASP.NET web page. When we open the page the Select method (here: GetCustomers) is called twice. Why? It is obvious performance hit as the data needs to be retrieved twice. How to avoid the duplicated calls?
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.