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

J

Joey

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
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top