Ciao a tutti.
Ho bisogno di applicare una funzione scritta in VB.net ad un controllo contenuto nel LayoutTemplate di una ListView DataBound. Nello specifico, la funzione serve a sostituire il testo di intestazioni, bottoni ecc.. con altri, presi da una tabella. Qui devo sostituire le intestazioni delle colonne. dunque, il LayoutTemplate ha la seguente forma:
Ora, quello che non riesco a capire, è perché non posso usare i controlli all'intero di questa tabella. Se, nel codice, provo a richiamare gli ID L_product_name, L_product_db ecc.., Visual Studio mi dice che i nomi non sono stati dichiarati (e ovviamente Intellisense non me li suggerisce). Ho sbagliato qualcosa?codice:<LayoutTemplate> <table runat="server"> <tr runat="server"> <td runat="server"> <table ID="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;"> <tr runat="server" style="background-color:#DCDCDC;color: #000000;"> <th runat="server"> <asp:Label ID="L_products_article" runat="server" Text="Article"></asp:Label> </th> <th runat="server"> <asp:Label ID="L_products_article_local" runat="server" Text="Article LOCAL"></asp:Label> </th> <th runat="server"> <asp:Label ID="L_product_name" runat="server" Text="Name"></asp:Label> </th> <th runat="server"> <asp:Label ID="L_product_db" runat="server" Text="Is DB"></asp:Label> </th> <th runat="server"> <asp:Label ID="L_product_frame" runat="server" Text="Is Frame"></asp:Label> </th> <th runat="server"> <asp:Label ID="L_product_active" runat="server" Text="Active"></asp:Label> </th> <th runat="server"> <asp:Label ID="L_product_price" runat="server" Text="Price"></asp:Label> </th> <th runat="server"> </th> </tr> <tr ID="itemPlaceholder" runat="server"> </tr> </table> </td> </tr> <tr runat="server"> <td runat="server" style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;"> <asp:DataPager ID="DataPager1" runat="server"> <Fields> <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" /> <asp:NumericPagerField /> <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" /> </Fields> </asp:DataPager> </td> </tr> </table> </LayoutTemplate>
Per applicare la funzione in questione, get_local_name(), devo richiamare i controlli col metodo FindControl, giusto? In tal caso, qualcuno mi spiegherebbe gentilmente come si usa questo metodo? Grazie a tutti.
P.S. Ad altri controlli, la funzione la applico semplicemente in questo modo
codice:Protected Sub select_local() L_admin.Text = get_local_name("Admins", lng) L_local_name.Text = get_local_name("Local Names", lng) L_customers.Text = get_local_name("Customers", lng) End Sub

Rispondi quotando