Ciao rsdpzed,
ho provato ad adattare lo script che mi hai gentilmente postato, ma purtroppo non funziona.
Il codefile è collegato alla master page, mentre la listview è sulla content page.
Rispetto al tuo script ho sostituito la parola "campo" con il nome del campo del db.
Ti faccio un piccolo riepilogo:
Pagina aspx:
codice:
<asp:Label ID="labelautore2" runat="server" Text='Autore2:' />
<asp:Label runat="server" Text='<%# Eval("autore2") %>' />
CodeFile:
codice:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class marmar : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
private Dictionary<string, string> ElencoCampi = new Dictionary<string, string>
{
{"autore2", "labelautore2"}
};
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
Label etichetta;
object valore;
System.Data.DataRowView rowView = e.Item.DataItem as System.Data.DataRowView;
foreach (var autore2 in ElencoCampi)
{
valore = rowView[autore2.Key].ToString();
if (null == valore)
{
etichetta = (Label)e.Item.FindControl(autore2.Value);
etichetta.Visible = false;
}
}
}
}
}
Ogni tuo aiuto è ben accetto.
Grazie,
Marco