Hi guys,
Very new to asp.net still in classic asp mode but I was wondering if anyone can help me.
I have a repeater pulling out data from a database.
Code:Dim txt_businesses_id txt_businesses_id = Request.QueryString("id") 'Create the connection and DataAdapter for the biz_categories table. Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("db/db_boston_dat.mdb")) ' Text Business Listings Dim cmd1 As New OleDbDataAdapter("select * from tbl_businesses WHERE biz_sub_categories_id = " & txt_businesses_id & "", cnn) 'Create and fill the DataSet. Dim ds As New DataSet() cmd1.Fill(ds, "tbl_businesses") 'Bind the tbl_biz_categories table to the parent Repeater control, and call DataBind. businesses.DataSource = ds.Tables("tbl_businesses") Page.DataBind()
Within the database I have a TRUE or FALSE field named ... business_webcheck
basically IF this field equals TRUE i would like it to display the businesses email and website address details if FALSE it should hide them to the user.
So I thought a classic way of doing this would be to use the .Visible property to its best and do something like this,
Code:email.visible = True web.visible = True
and within the actual repeater declare the web details ID like so,
Code:<asp:Repeater id="businesses" runat="server"> <ItemTemplate> <ul class="biz_item"> <li><a href=""><%#DataBinder.Eval(Container.DataItem, "(businesses_name)")%></a></li> <li><%#DataBinder.Eval(Container.DataItem, "(businesses_building)")%> <%#DataBinder.Eval(Container.DataItem, "(businesses_address1)")%> <%#DataBinder.Eval(Container.DataItem, "(businesses_address2)")%> <%#DataBinder.Eval(Container.DataItem, "(businesses_town)")%> <%#DataBinder.Eval(Container.DataItem, "(businesses_county)")%> <%#DataBinder.Eval(Container.DataItem, "(businesses_postcode)")%></li> <li class="float_left">Telephone: <%#DataBinder.Eval(Container.DataItem, "(businesses_telephone)")%></li> <li>Fax: <%#DataBinder.Eval(Container.DataItem, "(businesses_fax)")%></li> <li id="email" runat="server" class="float_left">E-mail: <%#DataBinder.Eval(Container.DataItem, "(businesses_email)")%></li> <li id="web" runat="server">Website: <%#DataBinder.Eval(Container.DataItem, "(businesses_website)")%></li> </ul> </itemtemplate> </asp:repeater>
Notice that I have ensured the runat="server" bit within the list tag element.
But even I have even attempted to get the IF statement within there I have a problem as the page returns a error saying the ID email has not been found on the page.
I have to actually take it OUT of the repeater to be abel to get that list element to hide and show. Which defeats the purpose of the whole process.
If anyone can shed any light on way my ID is not being picked up within my repeater can you let me know.
I have even tried down the lines of the list element is a child of the parent object of the repeater but didnt seem to get me anywhere.
Am I totally barking up the wrong tree?
Thanks,
Tim









Bookmarks