datalist control

G

Guest

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.
 
G

Guest

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;
 
G

Guest

thanks

HARI PRASD BARU said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top