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 / October 2007

Tip: Looking for answers? Try searching our database.

Double databinding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lloyd Sheen - 15 Oct 2007 18:03 GMT
I have a page just about ready to go and then I noticed all the databinding
on the page was happening twice (which really isn't nice).

I then created a small sample just to see what was going on.   The page
contains just a dropdown which is databound to a SQLDatasource.

When this runs with a breakpoint on the "Dim i As Integer = 1" line it show
a breakpoint twice on the load.

Any ideas???

Lloyd Sheen

Page Source:

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="TestAccordian.aspx.vb" Inherits="TestAccordian" %>

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
   Namespace="System.Web.UI" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <title>Test Databinding Problems</title>
</head>
<body>
   <form id="form1" runat="server">
       <asp:DropDownList ID="GenreList" runat="server"
DataSourceID="SqlDataSource1"
           DataTextField="Genre" DataValueField="Genre"
OnDataBound="GenreList_DataBound"
           ToolTip="Choose only artists tagged with this genre"
Width="100px">
       </asp:DropDownList>
       <asp:SqlDataSource ID="SqlDataSource1" runat="server"
           ConnectionString="<%$ ConnectionStrings:C:\DATABASE
FILES\MUSICINFODB.MDFConnectionString %>"
           SelectCommand="SELECT [Genre] FROM [AllGenres]">
       </asp:SqlDataSource>
   </form>
</body>
</html>

Code Behind :

Partial Class TestAccordian
   Inherits System.Web.UI.Page

   Protected Sub GenreList_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles GenreList.DataBound
       Dim i As Integer = 1
   End Sub
End Class
Peter Bromberg [C# MVP] - 15 Oct 2007 20:59 GMT
It *sounds* like you have autoEventWireup = true in the @Page declaration,
and then you *Also* have individual events wired up with delegates, which is
causing your event to fire twice.
-- Peter
Recursion: see Recursion
site:  http://www.eggheadcafe.com
unBlog:  http://petesbloggerama.blogspot.com
BlogMetaFinder:    http://www.blogmetafinder.com

> I have a page just about ready to go and then I noticed all the databinding
> on the page was happening twice (which really isn't nice).
[quoted text clipped - 53 lines]
>     End Sub
> End Class

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.