Applicare colori a repeater
Silver's
Silver's non è online. Ultima attività: 09/02/2010 9.24.54Silver's
il 3 luglio 2009 alle 15:56
100 messaggi dal 20 febbraio 2007
Ciao ragazzi,
io mi trovo davanti a questo problema, voler mettere un colore di sfondo al mio td in base ad un valore che estrapolo dal mio db.

Il problema e che devo poterlo fare in un repeater, ma non so come fare.

Ho provato così ma non mi funziona:

Pagina aspx

<asp:Repeater ID="Repeater" runat="server" DataSourceID="SqlDataSourceRepeater" OnItemDataBound="Repeater_ItemDataBound" Visible="false">
<HeaderTemplate> </HeaderTemplate>
<ItemTemplate>
<ASP:TABLE cellpadding="3" cellspacing="0" width="90%" ID="tabellaCheclist" runat="server">
<ASP:TABLEROW valign="baseline">
<ASP:TABLECELL FontColor='<%# FormatDate(DataBinder.Eval(Container,"DataItem.DateColumn")) %>'><%# FormatDate(DataBinder.Eval(Container,"DataItem.DateColumn")) %>

<asp:Label ID="L_ChList" Runat="server" CssClass="testo8pointblu" Text="Check" />
<br />
<asp:TextBox id="Txt_ChList" Text='<%# DataBinder.Eval(Container.DataItem, "NMCLPD") %>' Runat="server" Enabled="false" />
</ASP:TABLECELL>

<ASP:TABLECELL FontColor='<%# FormatDate(DataBinder.Eval(Container,"DataItem.DateColumn")) %>'><%# FormatDate(DataBinder.Eval(Container,"DataItem.DateColumn")) %>

<asp:Label ID="L_ChListSINO" Runat="server" CssClass="testo8pointblu" Text="Si / No" />
<br />
<asp:CheckBox id="Ch_ChList" runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "CHSINO") %>' />
</ASP:TABLECELL>

</ASP:TABLEROW>
</ASP:TABLE>
</ItemTemplate>

<AlternatingItemTemplate>
<ASP:TABLE cellpadding="3" cellspacing="0" width="90%" ID="tabellaCheclist2" runat="server">
<ASP:TABLEROW valign="baseline">

<ASP:TABLECELL bgcolor= "#FAB22B">

<asp:Label ID="L_ChList2" Runat="server" CssClass="testo8pointblu" Text=" Check" />
<br />
<asp:TextBox id="Txt_ChList2" Text='<%# DataBinder.Eval(Container.DataItem, "NMCLPD") %>' Runat="server" Enabled="false" />
</ASP:TABLECELL>
<ASP:TABLECELL bgcolor= "#FAB22B">
<asp:Label ID="L_ChListSINO2" Runat="server" CssClass="testo8pointblu" Text="Si / No" />
<br />
<asp:CheckBox id="Ch_ChList2" runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "CHSINO") %>' />
</ASP:TABLECELL>


</ASP:TABLECELL>
</ASP:TABLEROW>
</ASP:TABLE>
</AlternatingItemTemplate>

<FooterTemplate>

</FooterTemplate>
</asp:Repeater>


Pagina Aspx.vb
Protected Function FormatDate(ByVal dteDate As Date) As System.Drawing.Color

If Statocheckpdl = 1 Then
Return Drawing.Color.Green
Else
Return Drawing.Color.White
End If
End Function


Sapete come posso fare?
Pensavo ci fosse qualcosa qualche metodo nel OnItemDataBound ma non ho trovato nulla
Grazie a tutti in anticipo
Modificato da Silver's il 03 luglio 2009 15.57 -
Modificato da Silver's il 03 luglio 2009 16.05 -
RE: Applicare colori a repeater
Silver's
Silver's non è online. Ultima attività: 09/02/2010 9.24.54Silver's
il 3 luglio 2009 alle 16:23
100 messaggi dal 20 febbraio 2007
Ho provato seguendo questo link http://www.aspitalia.net/script/741/Personalizzare-Template-Repeater.aspx

ma mi da errore sulla riga
tRow.Style("background-color") = "red";


L'errore è:

Riferimento a un oggetto non impostato su un'istanza di oggetto.
Come mai?
RE: Applicare colori a repeater
nostromo
nostromo non è online. Ultima attività: 09/02/2010 11.49.13nostromo Top Poster
il 3 luglio 2009 alle 16:35
probabilmente quando fai:

TableRow tRow = (TableRow)e.Item.FindControl("tr");

non trovi l'oggetto TableRow

Chi parla senza modestia troverà difficile rendere buone le proprie parole.
Confucio

http://nostromo.spaces.live.com/default.aspx
RE: Applicare colori a repeater
Silver's
Silver's non è online. Ultima attività: 09/02/2010 9.24.54Silver's
il 3 luglio 2009 alle 16:45
100 messaggi dal 20 febbraio 2007
Adesso mi da questo errore sulla riga:
Dim tRow As TableRow = DirectCast(e.Item.FindControl("tr"), TableRow)

l'errore è questo

Impossibile eseguire il cast di oggetti di tipo 'System.Web.UI.HtmlControls.HtmlTableRow' sul tipo 'System.Web.UI.WebControls.TableRow'.

Nella mia pagina aspx il tr è così definito
<tr id="tr" runat="server">
<td><asp:Label ID="L_ChList" Runat="server" CssClass="testo8pointblu" Text="Check" />
<br />
<asp:TextBox id="Txt_ChList" Text='<%# DataBinder.Eval(Container.DataItem, "NMCLPD") %>' Runat="server" Enabled="false" />
</td>
<td bgcolor= "#FAB22B">
<asp:Label ID="L_ChListSINO" Runat="server" CssClass="testo8pointblu" Text="Si / No" />
<br />
<asp:CheckBox id="Ch_ChList" runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "CHSINO") %>' /> </td>
</tr>


mannaggia dov'è che sbaglio?
RE: Applicare colori a repeater
Silver's
Silver's non è online. Ultima attività: 09/02/2010 9.24.54Silver's
il 3 luglio 2009 alle 17:04
100 messaggi dal 20 febbraio 2007
Domanda, ma solo sull'onItemCreated si può fare?
Perchè lo sto usando nell' OnItemDataBound.

Lo so che vi stresso ma non riesco proprio a capire dov'è che sbaglio
RE: Applicare colori a repeater
Silver's
Silver's non è online. Ultima attività: 09/02/2010 9.24.54Silver's
il 3 luglio 2009 alle 18:14
100 messaggi dal 20 febbraio 2007
Ho risolto evvai.
Il problema era che avevo messo table normalmente, mentre ho provato con <Asp:table> e di conseguenza i tag <asp:tablerow> e <asp:tablecell> ed è andato.

Grazie mille a tutti soprattutto per la pazienza
RE: Applicare colori a repeater
nostromo
nostromo non è online. Ultima attività: 09/02/2010 11.49.13nostromo Top Poster
il 3 luglio 2009 alle 18:24
scusa se non ti ho risposto prima, non ho notato i messaggi successivi, comunque ci sei arrivato da solo :D

Chi parla senza modestia troverà difficile rendere buone le proprie parole.
Confucio

http://nostromo.spaces.live.com/default.aspx

 

Torna al forum |   Feed RSS
ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.
COMMUNITY
ULTIMI MESSAGGI
UTENTI ONLINE
MEDIA
IN EVIDENZA
MISC
Powered by .db Forums "Caesar Reborn" v. 2010.2.8