Re: adding a new datarow to a datalist at runtime?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: W.G. Ryan [eMVP] (WilliamRyanATGmailDotcom)
Date: 09/07/04


Date: Tue, 7 Sep 2004 19:07:43 -0400

Dim dr as DataRow = dataTableName.NewRow
'Set the avlues here
dataTableName.Rows.Add(dr)
"Joey" <joey_no_spam@digital.com> wrote in message
news:utKMTmXkEHA.3788@TK2MSFTNGP14.phx.gbl...
> 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
>
>



Relevant Pages

  • Re: TextBox Update Problem
    ... 'Display next message in Message Center - this does not work ... Dim objPathOUT ... Public Sub OutPutFolder_Click(ByVal sender As System.Object, ...
    (microsoft.public.vb.general.discussion)
  • Re: Really need help today if possible
    ... > I need to display the result in SQLWhere in this section ... > Public Sub CommandButtonNextGroupId_Click ... > Dim i As Integer ... > ' Clear ListBoxClass ...
    (microsoft.public.excel.programming)
  • Re: Better solution ?
    ... > I'm trying to display into a system.Web.UI.WebControls.Image a picture ... > Public Sub GetBlobInfo ... > Dim cmd As New SqlCommand("SELECT Picture FROM mytable WHERE ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Better solution ?
    ... I'm trying to display into a system.Web.UI.WebControls.Image a picture coming from the DB. ... Public Sub GetBlobInfo ... Dim cmd As New SqlCommand ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SQL access from Cobol Test
    ... Dim oWrite As System.IO.StreamWriter ... Dim workline As String ... 000380 01 NEW-GENERIC-REC. ... 000810 DISPLAY "INVALID READ FROM IMPORT TEXT FILE". ...
    (comp.lang.cobol)