datalist control

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

  1. Guest

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

  3. Guest

    Guest Guest

    thanks

     
    Guest, Aug 31, 2005
    #3
  4. Guest

    sftwin

    Joined:
    Apr 16, 2008
    Messages:
    1
    Likes Received:
    0
    Try this...

     
    sftwin, Apr 16, 2008
    #4
    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.