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