Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

ObjectDataSource OnSelected event raised twice

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
chris.c.woodward@gmail.com - 10 Jul 2007 15:25 GMT
This event seems to be being raised twice in my codebehind. I have
only one SelectMethod and do not have a SelectCountMethod. 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_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
   {
       Response.Write("event called");
       Response.Write("<br />");

       if (e.ReturnValue != null)
       {
           PagedDataSource pds = (PagedDataSource)e.ReturnValue;
           totalRowCount = pds.DataSourceCount;

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

           if (PlaceHolder1.Controls.Count == 0)
           {
               Control control1 = Page.LoadControl("~/UserControls/
NumericPager.ascx");
               UserControls_NumericPager numericPager1 =
(UserControls_NumericPager)control1;
               numericPager1.PageCount = pageCount;
               numericPager1.PageIndex = pageIndex;
               PlaceHolder1.Controls.Add(numericPager1);
           }
       }
   }

Anybody got any ideas why this event is being called twice?
nahid - 10 Jul 2007 23:59 GMT
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 SelectCountMethod. Its causing
[quoted text clipped - 32 lines]
>
> 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
chris.c.woodward@gmail.com - 11 Jul 2007 09:35 GMT
Thanks for your reply.

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

<asp:DataList ID="dlCatalogues" runat="server"
DataSourceID="odsCatalogues" EnableViewState="false">

    ...

</asp:DataList>

<asp:ObjectDataSource ID="odsCatalogues" runat="server"
SelectMethod="SelectCatalogues" TypeName="AGT.Business.EventDB"
OnSelected="odsCatalogues_Selected"
OnSelecting="odsCatalogues_Selecting">
    <SelectParameters>
        <asp:Parameter ... />
        <asp:ControlParameter ... /

        <asp:QueryStringParameter ... /

        <asp:QueryStringParameter ... /

        <asp:QueryStringParameter ... /

        <asp:Parameter ... />
    </SelectParameters>
</asp:ObjectDataSource>
nahid - 11 Jul 2007 10:45 GMT
On Jul 11, 2:35 pm, chris.c.woodw...@gmail.com wrote:
> Thanks for your reply.
>
[quoted text clipped - 25 lines]
>         </SelectParameters>
> </asp:ObjectDataSource>

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
chris.c.woodward@gmail.com - 11 Jul 2007 15:40 GMT
Think I've figured out what was going on.

The ObjectDataSource markup contained this line:

<asp:ControlParameter DefaultValue="0" Name="clientId" Type="Int32"
ControlID="DDList1" PropertyName="SelectedValue" />

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

Replacing the line with:

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

and setting the value in the ObjectDataSource Selecting event:

protected void odsCatalogues_Selecting(object sender,
ObjectDataSourceSelectingEventArgs e)
{
       e.InputParameters["clientId"] =
Convert.ToInt32(DDList1.SelectedValue);
}

meant that my DataList databinding was now not occurring twice.

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

:)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.