Salve raga!! Il datalist finalmente funziuona come voglio!!! Praticamente ho creato un barra OUTLOOK!!! conun effetto molto carino!
Cmq, ora devo dire alla datalist che si deve fermare con la creazione dei link se trova una cella del database vuota:
ovvero se il <%#Container.DataItem("imgL4") corrisponde ad una cella vuota del database, non deve eseguire la costruzione della <TD> ma non so come impostare il costrutto if, mi da questo messaggio:codice:<% if ( %> <%#Container.DataItem("imgL4") != vuoto) then %> <tr> <td> [img]<%# Container.DataItem("imgL4") %>[/img] </td> <td> <%# Container.DataItem("testoL4") %> </td> </tr> <% end if %> </tbody>
Messaggio di errore del compilatore: BC30201: Prevista espressione corrispondente all'if.
Grazie anticipatamente
P.s. Il codice della mia datalist funzuionante!!
codice:<%@ Page Language="VB" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.SqlClient" %> <script runat="server"> Sub Page_Load if Not Page.IsPostBack then BindList() end if End Sub Sub BindList() Dim ConnectionString As String = "server=(local);database=menu;user=sa" Dim CommandText As String = "select * from menu1" Dim myConnection As New SqlConnection(ConnectionString) Dim myCommand As New SqlDataAdapter(CommandText, myConnection) Dim ds As New DataSet() myCommand.Fill(ds,"menu1") DataList1.DataSource = ds.Tables("menu1") DataList1.DataBind() End Sub Private Sub DataList1_ItemCommand(ByVal obj As Object, ByVal e As DataListCommandEventArgs) Select (CType(e.CommandSource, LinkButton)).CommandName Case "Open" DataList1.SelectedIndex = e.Item.ItemIndex BindList() Case "Close" DataList1.SelectedIndex = -1 BindList() End Select End Sub </script> <html> <head> <link href="/menu.css" type="text/css" rel="stylesheet" /> </head> <body> <form runat="server"> <asp:DataList id="DataList1" runat="server" Font-Names="Verdana" Font-Name="Verdana" Font-Size="8pt" Width="150px" DataKeyField="pulsID" OnItemCommand="DataList1_ItemCommand" ShowHeader="False" CssClass=".puls"> <SelectedItemTemplate> <table id="tSel" cellspacing="0" cellpadding="0" width="200" background="/img/item_bg.gif"> <tbody> <tr> <td onmouseover="tSel.background='/img/item_over.gif'" onmouseout="tSel.background='/img/item_bg.gif'"> <asp:LinkButton id="button1" Font-Bold="True" Font-Size="Medium" ForeColor="Black" CommandName="Close" Text='<%# Container.DataItem("testoPuls") %>' runat="server"></asp:LinkButton> </td> </tr> </tbody> </table> <table cellspacing="0" cellpadding="0" width="200" background="/img/group_bg.gif"> <tbody> <tr> <td> [img]<%# Container.DataItem("imgL1") %>[/img]</td> <td> <%# Container.DataItem("testoL1") %></td> </tr> <tr> <td> [img]<%# Container.DataItem("imgL2") %>[/img]</td> <td> <%# Container.DataItem("testoL2") %></td> </tr> <tr> <td> [img]<%# Container.DataItem("imgL3") %>[/img] </td> <td> <%# Container.DataItem("testoL3") %> </td> </tr> <tr> <td> [img]<%# Container.DataItem("imgL4") %>[/img] </td> <td> <%# Container.DataItem("testoL4") %> </td> </tr> </tbody> </table> </SelectedItemTemplate> <ItemTemplate> <table id="tIte" cellspacing="0" cellpadding="0" width="200" background="/img/item_bg.gif"> <tbody> <tr> <td onmouseover="tIte.background='/img/item_over.gif'" onmouseout="tIte.background='/img/item_bg.gif'"> <asp:LinkButton id="button1" Font-Bold="True" Font-Size="Medium" ForeColor="Black" CommandName="Open" Text='<%# Container.DataItem("testoPuls") %>' runat="server"></asp:LinkButton> </td> </tr> </tbody> </table> </ItemTemplate> </asp:DataList> </form> </body> </html>

Rispondi quotando
