Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > datalist control

Reply
Thread Tools

datalist control

 
 
=?Utf-8?B?QW5kcmV3?=
Guest
Posts: n/a
 
      08-30-2005
Hi,

How do I access the cells of a table that is located in a datalist control ?
I have the datalist control and some asp controls in it up n it is working
fine. My datalist is bound to a dataset.

I want to put in an if-else statement that states that if an array element
equals 1 (default 0), then the bgcolor of a particular cell is RED. Below I
have given a sniplet of my code:

MyDataList.DataSource = dsSA.Tables["StudentAnswer"];
MyDataList.DataBind();

//array of 20 elements, of value either 1 or 0.
int [] setmarkcolor = (int[])Session["marked"];
eg. setmarkcolor[0] = 1;

This is in my .aspx file and I have given a sample of the cell that I want
to change the bgcolor below:

<asp:datalist id="MyDataList" Runat="server" RepeatColumns="0"
OnItemDataBound="MyDataList_ItemDataBound">
<ItemTemplate>
<TABLE id = "TableR">
<TR align="center">
<TD style="WIDTH: 18px; HEIGHT: 23px"><A href="Question.aspx?
questionId=1">1.</A>
</TD>
<TD style="WIDTH: 149px; HEIGHT: 23px" bgcolor="#00ffff"><%#
DataBinder.Eval(Container.DataItem, "studentAnswer1")%>
</TD>
</TABLE>
</asp:datalist>


I hope my explanation is understandable. If not, just ask n I will clarify
further.
TIA.
Andrew.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SEFSSSBQUkFTRCBCQVJV?=
Guest
Posts: n/a
 
      08-30-2005
Hi Andhrew

change tr/td as servre tablecell/tablerow... and access the same control in
the item databound using tablecell t = e.Item.FindControl("UR Cell ID");
and now t.BackColor = UR Color;

> Hi,
>
> How do I access the cells of a table that is located in a datalist control ?
> I have the datalist control and some asp controls in it up n it is working
> fine. My datalist is bound to a dataset.
>
> I want to put in an if-else statement that states that if an array element
> equals 1 (default 0), then the bgcolor of a particular cell is RED. Below I
> have given a sniplet of my code:
>
> MyDataList.DataSource = dsSA.Tables["StudentAnswer"];
> MyDataList.DataBind();
>
> //array of 20 elements, of value either 1 or 0.
> int [] setmarkcolor = (int[])Session["marked"];
> eg. setmarkcolor[0] = 1;
>
> This is in my .aspx file and I have given a sample of the cell that I want
> to change the bgcolor below:
>
> <asp:datalist id="MyDataList" Runat="server" RepeatColumns="0"
> OnItemDataBound="MyDataList_ItemDataBound">
> <ItemTemplate>
> <TABLE id = "TableR">
> <TR align="center">
> <TD style="WIDTH: 18px; HEIGHT: 23px"><A href="Question.aspx?
> questionId=1">1.</A>
> </TD>
> <TD style="WIDTH: 149px; HEIGHT: 23px" bgcolor="#00ffff"><%#
> DataBinder.Eval(Container.DataItem, "studentAnswer1")%>
> </TD>
> </TABLE>
> </asp:datalist>
>
>
> I hope my explanation is understandable. If not, just ask n I will clarify
> further.
> TIA.
> Andrew.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QW5kcmV3?=
Guest
Posts: n/a
 
      08-31-2005
thanks

"HARI PRASD BARU" wrote:

> Hi Andhrew
>
> change tr/td as servre tablecell/tablerow... and access the same control in
> the item databound using tablecell t = e.Item.FindControl("UR Cell ID");
> and now t.BackColor = UR Color;
>
> > Hi,
> >
> > How do I access the cells of a table that is located in a datalist control ?
> > I have the datalist control and some asp controls in it up n it is working
> > fine. My datalist is bound to a dataset.
> >
> > I want to put in an if-else statement that states that if an array element
> > equals 1 (default 0), then the bgcolor of a particular cell is RED. Below I
> > have given a sniplet of my code:
> >
> > MyDataList.DataSource = dsSA.Tables["StudentAnswer"];
> > MyDataList.DataBind();
> >
> > //array of 20 elements, of value either 1 or 0.
> > int [] setmarkcolor = (int[])Session["marked"];
> > eg. setmarkcolor[0] = 1;
> >
> > This is in my .aspx file and I have given a sample of the cell that I want
> > to change the bgcolor below:
> >
> > <asp:datalist id="MyDataList" Runat="server" RepeatColumns="0"
> > OnItemDataBound="MyDataList_ItemDataBound">
> > <ItemTemplate>
> > <TABLE id = "TableR">
> > <TR align="center">
> > <TD style="WIDTH: 18px; HEIGHT: 23px"><A href="Question.aspx?
> > questionId=1">1.</A>
> > </TD>
> > <TD style="WIDTH: 149px; HEIGHT: 23px" bgcolor="#00ffff"><%#
> > DataBinder.Eval(Container.DataItem, "studentAnswer1")%>
> > </TD>
> > </TABLE>
> > </asp:datalist>
> >
> >
> > I hope my explanation is understandable. If not, just ask n I will clarify
> > further.
> > TIA.
> > Andrew.

 
Reply With Quote
 
sftwin sftwin is offline
Junior Member
Join Date: Apr 2008
Posts: 1
 
      04-16-2008
Try this...

Quote:

<%#IIf(DataBinder.Eval(Container.DataItem, "studentAnswer1") = "1", "<b>COLOR RED</b> Text Here", "")%>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Entering DataList EditItemTemplate from Outside of the DataList Luis Esteban Valencia ASP .Net 1 01-06-2005 07:32 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
Click event in a datalist to post back datalist properties Steve Lloyd ASP .Net 1 05-26-2004 04:07 AM
DataList in DataList acko bogicevic ASP .Net 2 11-11-2003 08:31 AM
Datalist in Datalist How? Gönen EREN ASP .Net 0 08-22-2003 02:41 PM



Advertisments