adding a row to a datalist control at runtime? - Please Help

Discussion in 'ASP .Net Web Controls' started by Joey, Sep 6, 2004.

  1. Joey

    Joey Guest

    Hi There,

    I am still resonably new to asp .net and I have a datalist which I am using
    to display search results, one of the columns has a status in it and in this
    particular case I am wanting to display an image on top of each row that
    returns a status of sold (reuturned from stored procedure,hidden from
    display). I had a play around with the function below and when I removed
    that tables from the datalist it seemed to be applying the changes
    correclty, I am just unsure about how I can add a new row dynamically bacsed
    on a literal value.

    Could someone help me out with somecode so I can get this working if
    possible?

    Joey



    !--- item template display

    <ItemTemplate>
    <tr bgcolor="d9d9d9" class="tabletext">
    <td align="center" width="100"><%# DataBinder.Eval(Container.DataItem,
    "ListingID") %></td>
    <td align="center" width="60"><%# DataBinder.Eval(Container.DataItem,
    "Manufacturer") %></td>
    <td align="center" width="100"><%# DataBinder.Eval(Container.DataItem,
    "model") %></td>
    <td align="center" width="70"><%# DataBinder.Eval(Container.DataItem,
    "quantity") %></td>
    <td align="center" width="140"> <asp:HyperLink CssClass="tablelink"
    runat="server" Text="Specfications"
    NavigateUrl='<%# "ListingDetails.aspx?ListingID=" &
    DataBinder.Eval(Container.DataItem, "listingID")%>' /></td>
    </tr>
    </ItemTemplate>





    !-- event handler

    Public Sub ItemDataBoundEventHandler(ByVal sender As Object, ByVal e As
    DataListItemEventArgs)

    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    ListItemType.AlternatingItem Then

    Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)

    Dim strStatus As String

    strStatus = CType(drv("status").Trim(), String)


    if strStatus = "Sold" Then

    e.Item.CssClass = "tabletext"

    e.Item.Font.Bold = True

    e.Item.BackColor = System.Drawing.Color.Aquamarine

    End If

    End If

    End Sub
     
    Joey, Sep 6, 2004
    #1
    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. Richard Wilson
    Replies:
    0
    Views:
    6,248
    Richard Wilson
    Feb 26, 2004
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,884
  3. H5N1
    Replies:
    0
    Views:
    2,724
  4. KK
    Replies:
    2
    Views:
    598
    Big Brian
    Oct 14, 2003
  5. D
    Replies:
    0
    Views:
    221
Loading...

Share This Page