datalist control

Discussion in 'ASP .Net' started by =?Utf-8?B?QW5kcmV3?=, Aug 30, 2005.

  1. 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.
     
    =?Utf-8?B?QW5kcmV3?=, Aug 30, 2005
    #1
    1. Advertising

  2. 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.
     
    =?Utf-8?B?SEFSSSBQUkFTRCBCQVJV?=, Aug 30, 2005
    #2
    1. Advertising

  3. 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.
     
    =?Utf-8?B?QW5kcmV3?=, Aug 31, 2005
    #3
  4. =?Utf-8?B?QW5kcmV3?=

    sftwin

    Joined:
    Apr 16, 2008
    Messages:
    1
    Try this...

     
    sftwin, Apr 16, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gönen EREN

    Datalist in Datalist How?

    Gönen EREN, Aug 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    413
    Gönen EREN
    Aug 22, 2003
  2. acko bogicevic

    DataList in DataList

    acko bogicevic, Nov 10, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,517
    acko bogicevic
    Nov 11, 2003
  3. Steve Lloyd
    Replies:
    1
    Views:
    706
    Rick Spiewak
    May 26, 2004
  4. Nevyn Twyll
    Replies:
    8
    Views:
    1,884
  5. Luis Esteban Valencia
    Replies:
    1
    Views:
    494
    John Saunders
    Jan 6, 2005
Loading...

Share This Page