dynamically change

Discussion in 'ASP .Net Datagrid Control' started by Saravanan Rathinavelu, Aug 20, 2003.

  1. I need to know how to modify the <asp:BoundColumn/> to
    N/A when the datafield value comes in as negative
    quantity and color it different on the ASP.Net DataGrid,
    help me. thanks

    -Saravanan.R-
     
    Saravanan Rathinavelu, Aug 20, 2003
    #1
    1. Advertising

  2. Hi Saravanan,

    You may change the negative quantity to N/A and color it in the
    DataGrid.ItemDataBound. The following is a code snippet for demonstration.
    You can modify it to meet your requirements.

    private void DataGrid1_ItemDataBound(object sender,
    System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType == ListItemType.Item
    ||e.Item.ItemType==ListItemType.AlternatingItem)
    {
    Label l=new Label ();
    l.Text ="N/A";
    l.ForeColor =Color.Red;
    if (Convert.ToInt32 (e.Item .Cells[3].Text)<0)e.Item
    .Cells[3].Controls.Add(l);
    }
    }

    Does this answer your question? Please let me know if you need more
    information

    Best regards,
    Lewis

    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    | Content-Class: urn:content-classes:message
    | From: "Saravanan Rathinavelu" <>
    | Sender: "Saravanan Rathinavelu" <>
    | Subject: dynamically change
    | Date: Wed, 20 Aug 2003 13:47:29 -0700
    | Lines: 6
    | Message-ID: <044901c3675c$45234f60$>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="iso-8859-1"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | Thread-Index: AcNnXEUjcshcGR3xT4afTQqucDH0SA==
    | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | Path: cpmsftngxa06.phx.gbl
    | Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet.datagridcontrol:6294
    | NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    |
    | I need to know how to modify the <asp:BoundColumn/> to
    | N/A when the datafield value comes in as negative
    | quantity and color it different on the ASP.Net DataGrid,
    | help me. thanks
    |
    | -Saravanan.R-
    |
     
    Lewis Wang [MSFT], Aug 21, 2003
    #2
    1. Advertising

  3. Saravanan Rathinavelu

    Stevie_mac Guest

    In DataGrid_ItemDataBound(...)
    Dim lbl as Label
    lbl = CType(e.Item.Cells(0).Controls(1), Label)
    If Val(lbl.Text) < 0 Then
    lbl.Text = "N/A"
    e.Item.Cells(0).BackColor = Color.Red
    End If

    The Label, when rendered, is enclosed in a literal - so Cells(0).Controls(0)
    will not get your control, Cells(0).Controls(1) will be your control. In the
    example above, i dim a label & cast the contents of Cell 0 Control 1 to it.



    "Saravanan Rathinavelu" <> wrote in message
    news:044901c3675c$45234f60$...
    > I need to know how to modify the <asp:BoundColumn/> to
    > N/A when the datafield value comes in as negative
    > quantity and color it different on the ASP.Net DataGrid,
    > help me. thanks
    >
    > -Saravanan.R-
     
    Stevie_mac, Aug 21, 2003
    #3
    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. Kevin Spencer
    Replies:
    6
    Views:
    1,012
    VB Programmer
    Jul 14, 2003
  2. =?Utf-8?B?UmV6YSBOYWJp?=

    Load User Control Dynamically, Cast object dynamically

    =?Utf-8?B?UmV6YSBOYWJp?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,804
    Matt Berther
    Mar 5, 2005
  3. =?Utf-8?B?UmV6YSBOYWJp?=

    Load User Control Dynamically, Cast object dynamically

    =?Utf-8?B?UmV6YSBOYWJp?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,374
    Scott Allen
    Mar 4, 2005
  4. Jeffrey Todd
    Replies:
    1
    Views:
    4,149
    Peter Blum
    Jun 2, 2005
  5. msimmons
    Replies:
    0
    Views:
    523
    msimmons
    Jul 16, 2009
Loading...

Share This Page