Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > dynamically change

Reply
Thread Tools

dynamically change

 
 
Saravanan Rathinavelu
Guest
Posts: n/a
 
      08-20-2003
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-
 
Reply With Quote
 
 
 
 
Lewis Wang [MSFT]
Guest
Posts: n/a
 
      08-21-2003
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.datagridc ontrol
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridc ontrol:6294
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
|
| 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-
|

 
Reply With Quote
 
 
 
 
Stevie_mac
Guest
Posts: n/a
 
      08-21-2003
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-



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
A Paradise DNS address change? What change? There was no change. Tony Neville NZ Computing 7 09-22-2006 01:02 PM
Inserting Controls Dynamically - with Validators Also Added Dynamically Jeffrey Todd ASP .Net 1 06-02-2005 04:33 PM
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-05-2005 12:04 AM
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-04-2005 07:57 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57