Binding NULL column causing Page_Load to run twice

Discussion in 'ASP .Net' started by T-Bone, Jul 6, 2004.

  1. T-Bone

    T-Bone Guest

    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
     
    T-Bone, Jul 6, 2004
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy

    Page_Load called twice???

    Andy, Oct 17, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    5,207
  2. H Branyan

    Page_Load fires twice

    H Branyan, Oct 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    836
    H Branyan
    Oct 22, 2003
  3. Jon
    Replies:
    1
    Views:
    12,030
    George Ter-Saakov
    Jan 13, 2004
  4. bminder
    Replies:
    1
    Views:
    2,360
    nfedin
    Feb 23, 2004
  5. z. f.
    Replies:
    0
    Views:
    727
    z. f.
    Oct 19, 2004
  6. Replies:
    5
    Views:
    30,229
    Mike Schilling
    Mar 29, 2006
  7. rockdale
    Replies:
    1
    Views:
    882
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 16, 2006
  8. Larry R
    Replies:
    1
    Views:
    496
    marss
    Jun 8, 2007
Loading...