Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Binding NULL column causing Page_Load to run twice (http://www.velocityreviews.com/forums/t82090-binding-null-column-causing-page_load-to-run-twice.html)

T-Bone 07-06-2004 12:24 PM

Binding NULL column causing Page_Load to run twice
 
Problem with page_load firing twice was driving me mad.
I had an aspx page with several webusercontrols in it.
One of them had a repeater with some databinders in it.
In my codebehing I bind a dataset to the repeater.
However when one of the values in my dataset (in my case field
'banLocation' holding the location of an banner) was a NULL value the
page was loaded a again after the databind() command. Just filling the
field in the table of my SQL server database with some value solved
the problem. Leaving the field NULL and removing the '' in the <IMG
SRC> tag solved it.

source of the webusercontrol:

<asp:repeater id="rptBanners" runat="server" EnableViewState="True">
<ItemTemplate>
<a href='click.aspx?id=<%#
Databinder.Eval(Container.DataItem,"banID") %>&url=<%#
Databinder.Eval(Container.DataItem,"banUrl") %>' target='<%#
Databinder.Eval(Container.DataItem,"banTarget") %>'>
<img src='<%# Databinder.Eval(Container.DataItem,"banLocation")
%>' border=0></a>
<asp:Label id="lblbanid" runat="server" Visible="False" Text='<%#
Databinder.Eval(Container.DataItem,"banID") %>'>
</asp:Label>
<br>
</ItemTemplate>
</asp:repeater>



codebehind:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim myConnection As New
SqlConnection(GetDBConnectionString)
Dim getbanners As New SqlDataAdapter("select * from
i_banners ", myConnection)
Dim banDS As New DataSet
getbanners.Fill(banDS)
Me.rptBanners.DataSource = banDS
Me.rptBanners.DataBind()
End If
End Sub


All times are GMT. The time now is 04:20 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.