datalist control

Discussion in 'ASP .Net' started by Guest, Aug 30, 2005.

  1. Guest

    Guest Guest


    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"];

    //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"
    <TABLE id = "TableR">
    <TR align="center">
    <TD style="WIDTH: 18px; HEIGHT: 23px"><A href="Question.aspx?
    <TD style="WIDTH: 149px; HEIGHT: 23px" bgcolor="#00ffff"><%#
    DataBinder.Eval(Container.DataItem, "studentAnswer1")%>

    I hope my explanation is understandable. If not, just ask n I will clarify
    Guest, Aug 30, 2005
    1. Advertisements

  2. Guest

    Guest 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;
    Guest, Aug 30, 2005
    1. Advertisements

  3. Guest

    Guest Guest


    Guest, Aug 31, 2005
  4. Guest


    Apr 16, 2008
    Likes Received:
    Try this...

    sftwin, Apr 16, 2008
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.